例题1-5 三整数排序《算法入门竞赛经典第二版》

输入3个整数,从小到大排序后输出。
样例输入:
20 7 33
样例输出:
7 20 33

#include <stdio.h>
#include <stdlib.h>
int 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",c,b,a);
    return 0;
}
发布了59 篇原创文章 · 获赞 10 · 访问量 5483

猜你喜欢

转载自blog.csdn.net/qq_43476433/article/details/104148676