#include<stdio.h>
int main(viod)
{
int a,b,c,max,min,mid,stemp1,stemp2,stemp3;
printf("请输入三个数,用逗号分隔");
scanf("%d,%d,%d",&a,&b,&c);
max=a;
max=max>b?max:b;
max=max>c?max:c;
min=c;
min=min<b?min:b;
min=min<a?min:a;
//mid=b<(a<c?a:c)?(a<c?a:c):b;
stemp1=a>b?a:b;//a,b 中较大的值
stemp2=a>c?a:c;//a,c 中较大的值
stemp3=b>c?b:c;//b,c 中较大的值
mid=stemp3<(stemp1< stemp2?stemp1:stemp2)?stemp3:(stemp1< stemp2?stemp1:stemp2);//三个数中最小的一个
printf("%d,%d,%d中最大数为:%d\n",a,b,c,max);
printf("%d,%d,%d中最小数为:%d\n",a,b,c,min);
printf("%d,%d,%d中位于中间的数为:%d\n",a,b,c,mid);
}
原文地址:http://www.cnblogs.com/sunli6772/p/3861115.html