给你一道题,让你编写一个C程序,输入a,b,c 3个值,输出其中最大者。你要怎么做

来源:百度知道 编辑:UC知道 时间:2024/06/22 08:23:51

#include <stdio.h>
main()
{
int a,b,c,t;
printf("input three numbers:");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
t=a;
a=b;
b=t;
}
if(b>c)
{
t=b;
b=c;
c=t;
}
printf("the max number is %d.\n",c);
}

书上一大推!

max=a>b?(a>c?a:c):(b>c?b:c);

#include<stdio.h>
void main()
{
int a,b,c;
printf("input the a,b and c:\n");
scanf("%d%d%d",&a,&b,&c);
printf("%d\n",a=(a>b?a:b)>c?(a>b?a:b):c);
}