- #include <iostream>
- using namespace std;
- int main()
- {
- int x;
- int y;
- int z;
-
- cout<<"請輸入三個數字電腦會幫您排列數字的大小"<<endl;
- cout<<"請輸入第一個數"<<endl;
- cin>>x;
- cout<<"請輸入第二個數"<<endl;
- cin>>y;
- cout<<"請輸入第三個數"<<endl;
- cin>>z;
- if(x>y&&y>z)
- {
- cout<<x<<">"<<y<<">"<<z<<endl;
- }
- else if(x>z&&z>y)
- {
- cout<<x<<">"<<y<<">"<<z<<endl;
- }
- else if(z>x&&x>y)
- {
- cout<<z<<">"<<x<<">"<<y<<endl;
- }
- else if(z>y&&y>x)
- {
- cout<<z<<">"<<y<<">"<<x<<endl;
- }
- else if(y>x&&x>z)
- {
- cout<<y<<">"<<x<<">"<<z<<endl;
- }
- else if(y>z&&z>x)
- {
- cout<<y<<">"<<z<<">"<<x<<endl;
- }
-
- system("pause");
- return 0;
- }
複製代碼 |