任務描述:
輸入3個整數,按由小到大的順序輸出(要求用指針或引用方法處理)
測試輸入:
4 91 51
預期輸出:
4 51 91
程序源碼:
#include <stdio.h> #include <iostream> using namespace std; void sort(int &a,int &b,int &c) { int temp; 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; } } int main() { // 請在此添加代碼 /********** Begin *********/ int a,b,c; cin>>a>>b>>c; sort(a,b,c); cout<<a<<" "<<b<<' '<<c; /********** End **********/ return 0; }