输入三个数,按从小到大的顺序输出,使用C语言编程
//输入三个数,按从小到大的顺序输出
#include<stdio.h>
int main()
{
int a,b,c,temp;
printf("输入三个数:");
scanf("%d%d%d",&a,&b,&c);
if(a>b) //使a小于b
{
temp=a;
a=b;
b=temp;
}
if(a>c) //使a小于c
{
temp=a;
a=c;
c=temp;
}
if(b>c) //使b小于c
{
temp=b;
b=c;
c=temp;
}
printf("重新排序后的三个数是 : %d,%d,%d",a,b,c);
return 0;
}
测试结果:
觉得有帮助的话,点个赞吧!