我是怎么想的,我前面學過兩個數比大小,比如有三個數,a b c,先比較a和b的大小,然后用那個較大的和c比較就得出最大的那個了。這個求三個數比大小的問題最后變化成 了兩個數比大小了。
int main()
{
int a = 0;
int b = 0;
int c = 0;
int max2 = 0;//保存兩個數中較大的那一個
int max3 = 0;//保存三個數中最大的那一個
scanf_s("%d %d %d",&a,&b,&c);
//先找出a b中較大的那一個
if (a > b)
{
max2 = a;
if (max2 > c)
{
printf("%d is the greatest",max2);
}
else
{
printf("%d is the greatest",c);
}
}
else
{
max2 = b;
if (max2 > c)
{
printf("%d is the greatest",max2);
}
else
{
printf("%d is the greatest",c);
}
}
}
