本篇作者将介绍如何使用C语言实现将数字从大倒小排序;

ps:这些文章都是作者在学习C语言的过程中学习和思考出的。

上代码:

#include<stdio.h>
int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);//输入要排序的三个数字
    if (a < b)
    {
        int tmp=a;
        a = b;
        b = tmp;
    }
    if (a < c)
    {
        int tmp=a;
        a = c;
        c = tmp;
    }
    if (b < c)
    {
        int tmp=b;
        b = c;
        c = tmp;
    }
    printf("%d>%d>%d\n", a, b, c);//打印出从大到小排序完的数字
    return 0;
}

注意在输入数字时不要忘记输入空格!

更多推荐

C语言实现三个数字的排序