返回列表 發帖

024 兩數字比大小

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;

  4. int main()
  5. {
  6.                 int x;
  7.                 int y;
  8.                 cout << "請輸入第一個數字:";
  9.                 cin >> x;
  10.                 cout << "請輸入第二個數字:";
  11.                 cin >> y;
  12.                 if(x > y)
  13.                 {
  14.                         cout << x << " > " << y <<endl;
  15.                 }
  16.                 else if( y > x )
  17.                 {
  18.                         cout << y << " > " << x <<endl;
  19.                 }
  20.                 else if( y = x )
  21.                 {
  22.                         cout << x << " = " << y <<endl;
  23.                 }
  24.                 system ("pause");
  25.         return 0;
  26. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

  1. #include <iostream>
  2. #include <cstdlib>

  3. using namespace std;

  4. int main()
  5. {
  6.         int i;
  7.         int j;
  8.         cout << "請輸入第一個數字:";
  9.         cin >> i;
  10.         cout << "請輸入第二個數字:";
  11.         cin >> j;
  12.         if(j > i)
  13.         {
  14.                 cout << j << ">" << i << endl;
  15.         }
  16.         else if(i > j)
  17.         {
  18.                 cout <<  i << ">" << j << endl;
  19.         }
  20.         else
  21.         {
  22.                 cout <<"兩個一樣大,都是" << i <<endl;
  23.         }
  24.     system("pause");
  25.     return 0;

  26. }
複製代碼

TOP

返回列表