/* to find the age of individuals according to youngest to oldest */
#include <stdio.h>
int main(void){
int age1, age2, age3, youngest, middle, oldest;
printf ("Enter the age of the first individual: ");
scanf ("%d", &age1);
printf ("Enter the age of the second individual: ");
scanf ("%d", &age2);
printf ("Enter the age of the third individual: ");
scanf ("%d", &age3);
if ((age1 == age2) && (age2 == age3)){
printf("All individuals have the same age of %d", &age2);
}
else (age1 != age2) && (age1 != age3) && (age2 != age3);{
youngest = age1;
if (age1 > age2)
youngest = age2;
if (age2 > age3)
youngest = age3;
middle = age1;
if (age1 > age2)
middle = age2;
if (age2 < age3)
middle = age2;
oldest = age1;
if (age1 < age2)
oldest = age2;
if (age2 < age3)
oldest = age3;
printf("%d is the youngest.\n", youngest);
printf("%d is the middle.\n", middle);
printf("%d is the oldest.\n", oldest);
}
return 0;
}
嗨我改变了我的代码,但显示仍然显示一个奇怪的数字,当我输入每个人的相同年龄。我如何做到这一点,如果每个人都有同样的年龄,那么只有说所有人都有相同年龄的线。请帮助我作为它的分级任务,并且即时遇到这个问题排序3个人的年龄
所有人的年龄都是63567321是最年轻的。 1是中间的。 1是最古老的。
'printf(“所有人的%d年龄都一样”,&age2);'Remove'&' - >'printf(“所有人的年龄都是%d \ n”,age2);' – BLUEPIXY
请学习如何正确缩进你的代码,我个人甚至不会尝试阅读代码像那样呈现。然后,这不是一个问题,而是你的调试器。 –
请勿[REPOST](https://stackoverflow.com/questions/45939540/sort-the-age-of-3-individuals)。 – gsamaras