算法训练 排序

http://lx.lanqiao.org/problem.page?gpid=T243

 算法训练 排序  
时间限制:1.0s   内存限制:512.0MB
    
问题描述
  编写一个程序,输入3个整数,然后程序将对这三个整数按照从大到小进行排列。
  输入格式:输入只有一行,即三个整数,中间用空格隔开。
  输出格式:输出只有一行,即排序后的结果。
  输入输出样例
样例输入
9 2 30
样例输出
30 9 2
 
分析:
 
一个字,水。
 
AC代码:
 
 1 #include <stdio.h>
 2 #include <algorithm>
 3 using namespace std;
 4 int main()
 5 {
 6     int a ,b ,c, t1, t2;
 7     scanf("%d%d%d",&a,&b,&c);
 8     t1 = max(max(a,b),c);
 9     t2 = min(min(a,b),c);
10     printf("%d %d %d
",t1 ,a + b + c - t1 - t2 , t2);
11     return 0;
12 }
View Code
原文地址:https://www.cnblogs.com/jeff-wgc/p/4450386.html