返回列表 發帖
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.    int x;
  6.    int y;
  7.    int z;
  8.    
  9.    cout<<"請輸入三個數字電腦會幫您排列數字的大小"<<endl;
  10.    cout<<"請輸入第一個數"<<endl;
  11.    cin>>x;
  12.    cout<<"請輸入第二個數"<<endl;
  13.    cin>>y;
  14.    cout<<"請輸入第三個數"<<endl;
  15.    cin>>z;
  16.    if(x>y&&y>z)
  17.       {
  18.             cout<<x<<">"<<y<<">"<<z<<endl;
  19.       }
  20.    else if(x>z&&z>y)
  21.       {
  22.             cout<<x<<">"<<y<<">"<<z<<endl;
  23.       }
  24.    else if(z>x&&x>y)
  25.       {
  26.              cout<<z<<">"<<x<<">"<<y<<endl;
  27.       }
  28.    else if(z>y&&y>x)
  29.       {
  30.              cout<<z<<">"<<y<<">"<<x<<endl;
  31.       }  
  32.    else if(y>x&&x>z)
  33.       {
  34.              cout<<y<<">"<<x<<">"<<z<<endl;
  35.       }  
  36.    else if(y>z&&z>x)
  37.       {
  38.              cout<<y<<">"<<z<<">"<<x<<endl;
  39.       }   
  40.   
  41.    system("pause");
  42.    return 0;   
  43. }
複製代碼

TOP

返回列表