看书去吧,例题哦,...
#include<stdio.h>
main(viod)
{float a,b,c,t;
scanf("%f,%f,%f\n",&a,&b,&c,&t);
if(a>b)
{t=a;a=b;b=t;}
if(b>c)
{t=b;b=c;c=t;}
if(a>c)
{t=a;a=c;c=t;}
printf("%.2f,%.2f,%.2f",a,b,c);
getch();
}
/* 不进行排序,只是用 if 进行比较,最多进行 3 次比较。 */
#include <stdio.h>
int main(void)
{
int a, b, c;
while(scanf("%d %d %d", &a, &b, &c) == 3)
{
if(a > b)
{
if(b > c)
printf(" %d %d %d\n", c, b, a);
else if(a > c)
printf(" %d %d %d\n", b, c, a);
else
printf(" %d %d %d\n", b, a, c);
}
else
{
if(a > c)
printf(" %d %d %d\n", c, a, b);
else if(c > b)
printf(" %d %d %d\n", a, b, c);
else
printf(" %d %d %d\n", a, c, b);
}
}
return 0;
}