pxxfxxxxx

导航

(if述句)用两个变数的数值交换对三个变数做排序

#include <stdio.h>
int main()
{
    int a,b,c,t;
    scanf("%d%d%d",&a,&b,&c);
    printf("Before :%d %d %d\n",a,b,c);
    if (b > a)
    {
        t = b;
        b = a;
        a = t;

    }
    if (c < a)
    {
        t = c;
        c = a;
        a = c;
    }
    if (c < b)
    {
        t = c;
        c = b;
        b = t;
    }
    printf("After: %d %d %d\n",a,b,c);
    return 0;

}

 

posted on 2019-04-15 16:20  pxxfxxxxx  阅读(189)  评论(0编辑  收藏  举报