#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d,%d,%d",&a,&b,&c);
if(a>b)
{if(a>c)
printf("%d\n",a);
else
printf("%d\n",c);}
else
{
if(b>c)
printf("%d\n",b);
else
printf("%d\n",c);}
return 0;
}
利用三元运算符简化过程
#include <stdio.h>
int main()
{ int a,b,c,temp,max;
printf("请输入三个整数:");
scanf("%d,%d,%d",&a,&b,&c);
temp=(a>b)?a:b; /*将a和b中的大者存入temp中*/
max=(temp>c)?temp:c; /*将a和b中的大者与c比较,取最大者*/
printf("三个整数的最大数是%d\n",max);
return 0;
}
#include<stdio.h>
int main()
{
int a,b,c;
printf("please input three Integers:");
scanf("%d,%d,%d",&a,&b,&c);
if(a<b)
{
if(b<c)
printf("The max number is %d",c);
else
printf("The max number is %d",b);
}
else
{
if(c<a)
printf("The max number is %d",a);
else
printf("The max number is %d",c);
}
return 0;
}
如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢