本帖最後由 t3742238 於 2011-11-12 16:49 編輯
- #include <iostream>
- using namespace std;
- int main()
- {
- int a, b , c , d , e , f , g;
- cout<<"請輸入第1個數: ";
- cin>>a;
- cout<<"請輸入第2個數: ";
- cin>>b;
- cout<<"請輸入第3個數: ";
- cin>>c;
- cout<<"請輸入第4個數: ";
- cin>>d;
- e=(a>b)?a:b;
- f=(e>c)?e:c;
- g=(f>d)?g:f;
- cout<<"四個數中較大的數為"<<g;
- cout<<endl;
- system("pause");
- return 0;
- }
複製代碼 |