題目:輸入三個整數x,y,z,請把這三個數由小到大輸出
代碼如下
#include <stdio.h>
/**
* 輸入三個整數x,y,z,請把這三個數由小到大輸出。
* create by hangli on 2019/11/03
*/
#include <stdio.h>
int main(int argc, char *argv[])
{
int a, b, c, t;
printf("請輸入三個整數,彼此間用空格分隔:");
scanf("%d %d %d", &a, &b, &c);
if (a > b)
{
t = b;
b = a;
a = t;
}
if (a > c)
{
t = c;
c = a;
a = t;
}
if (b > c)
{
t = c;
c = b;
b = t;
}
//對三個數進行簡單的排序
printf("%d,%d,%d", a,b,c);
system("PAUSE");
}