用switch来判断三个数的最大值和最小值
#include<stdio.h>void main()
{
int a,b,c,max,min;
printf("请输入三个数字:\n");
scanf("%d%d%d",&a,&b,&c);
switch(a>b)
{
case 1:max=a,min=b;break;
case 0:max=b,min=a;
}
switch(max<c)
{
case 1:max=c;
}
switch(min>c)
{
case 1:min=c;
}
printf("max=%d,min=%d\n",max,min);
}
页:
[1]