c语言编程题 从键盘上输入3个数a b c 按照升序排列后输出 怎么编啊

如题所述

#include <stdio.h>
main()
{
float a,b,c,temp;
//输入a b c以空格隔开
scanf("%f%f%f",&a,&b,&c);
if (a>b)
{//如果a大于b则将a和b进行互换
temp=a;a=b;b=temp;
}
if (a>c)
{//如果a大于c则将a和c进行互换
temp=a;a=c;c=temp;
}
if (b>c)
{//如果b大于c则将b和c进行互换
temp=b;b=c;c=temp;
}
//打印a b  c
printf("%f%f%f",a,b,c);
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-19
/*若为实数,请将int替换为float或double,并将%d相应地替换为%f或%lf*/
#include <stdio.h>
main()
{
int a,b,c,temp;
scanf("%d%d%d",&a,&b,&c);
if (a>b)
{temp=a;a=b;b=temp;}
if (a>c)
{temp=a;a=c;c=temp;}
if (b>c)
{temp=b;b=c;c=temp;}
printf("%d%d%d",a,b,c);
}本回答被提问者采纳