C语言求三个数最大数和最小值
/*
求三个数最大值和最小值
*/
#include <stdio.h>
int main()
{
//三目运算符
int a=10,b=20,c=30;
int max;
max = a>b ? a:b;
max = (max = a>b ? a:b) > c ? max : c;
printf("Max is:%d\n",max);
if (a>b)
{
max=a;
if (max>c){
printf("Maximum is:%d\n",max);
}
else
max=c;
printf("Maximum is:%d\n",max);
}
else{
max=b;
if (max>c){
printf("Maximum is:%d\n",max);
}
else{
max=c;
printf("Maximum is:%d\n",max);
}
}
return 0;
}