描述
现在要写一个程序,实现给三个数排序的功能
-
输入
- 输入三个正整数 输出
给输入的三个正整数排序
分析
申请一个临时变量
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b,c;
int 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\n",a,b,c);
// system("pause");
return 0;
}