三个数从小到大排序
时间限制:
3000 ms | 内存限制:
65535 KB
难度:
0
-
描述
-
现在要写一个程序,实现给三个数排序的功能
-
输入
- 输入三个正整数 输出
- 给输入的三个正整数排序 样例输入
-
20 7 33
样例输出
-
7 20 33
来源
- [张洁烽]原创 上传者
代码:
#include <iostream> #include <stdio.h> #include <string.h> #include <math.h> #include <vector> #include <queue> #include <stack> #include <map> #include <string> #include <algorithm> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char** argv) { int a,b,c; scanf("%d%d%d",&a,&b,&c); 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(b>a){ if(a>c){ printf("%d %d %d\n",c,a,a); }else{ if(b>c){ printf("%d %d %d\n",a,c,b); }else{ printf("%d %d %d\n",a,b,c); } } } return 0; }