返回列表 發帖

五則運算(二)

透過使用者自行輸入數值 來計算簡單的五則運算
  1. #include<cstdlib>
  2. #include<iostream> // I (Input)O (Output) 串流
  3. using namespace std;
  4. int main()
  5. {
  6.     int x,y; //同時宣告x,y為int型別
  7.    
  8.     cout << "請輸入X的值\r\n";
  9.     cin >>  x;
  10.     cout << "請輸入y的值\r\n";
  11.     cin >> y;
  12.    
  13.     cout << "當x的值為:" <<x <<";當y的值為:" << y <<endl;
  14.    
  15.     cout << "x+y=" << x+y << endl;
  16.     cout << "x-y=" << x-y << endl;
  17.     cout << "x*y=" << x*y << endl;
  18.     cout << "x/y=" << x/y << endl;
  19.     cout << "x%y=" << x%y << endl;
  20.    
  21.     system("pause");   
  22.     return 0;
  23. }
複製代碼

返回列表