#include <stdio.h> int main() { int a,b,c,t; /*定義4個基本整型變數a、b、c、t*/ printf("Please input a,b,c:n"); /*雙引號內的普通字元原樣輸出並換行*/ scanf("%d,%d,%d",&a,&b,&c); /*輸入任意3個數*/ if(a>b) /*如果a大於b,借助中間變數t實現a與b值的互換*/ { t = a; a = b; b = t; } if(a>c) /*如果a大於c,借助中間變景t實現a與c值的互換*/ { t = a; a = c; c = t; } if(b>c) /*如果b大於c,借助中間變數t實現b與c值的互換*/ { t = b; b = c; c = t; } printf("The order of the number is:n"); printf("%d,%d,%d",a,b,c); /*輸出函數順序輸出a、b、c的值*/ return 0; }
Please input a,b,c:
5,3,9
The order of the number is:
3,5,9