第1个回答 推荐于2017-11-12
int main(void)
{
float a, b, c, t;
printf("输入任意三个数:");
scanf_s("%f,%f,%f", &a, &b, &c);
if (a > b)
{
t = a;
a = b;
b = t;
}
if (a > c)
{
t = a;
a = c;
c = t;
}
if (b > c)
{
t = b;
b = c;
c = t;
}
printf("%5.2f,%5.2f,%5.2f,\n", a, b, c);
}本回答被网友采纳
第2个回答 2011-07-29
if(a<b)&(a<c)
{
if(b<c)
print ("%d,%d,%d",a,b,c);
else
print ("%d,%d,%d",a,c,b);
}
if(b<a)&(b<c)
{
if(a<c)
print ("%d,%d,%d",b,a,c);
else
print ("%d,%d,%d",b,c,a);
}
if(c<b)&(c<a)
{
if(a<b)
print ("%d,%d,%d",c,a,b);
else
print ("%d,%d,%d",c,b,a);
}本回答被提问者采纳
第3个回答 2011-07-29
用宏处理:
#include <stdio.h>
#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)<(b))?(a):(b)
int main(int argc, char *argv[])
{
int a,b,c;
while(1)
{
scanf("%d %d %d",&a,&b,&c);
printf("max is: %d\n",max(max(a,b),c));
if((max(a,b)) != (max(a,c)))
printf("middle is: %d\n",min(max(a,b),max(a,c)));
else
printf("middle is: %d\n",max(b,c));
printf("min is: %d\n",min(min(a,b),c));
}
system("PAUSE");
return 0;
}