返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;

  4. int main()
  5. {
  6.                 int x;
  7.         cout << "輸入起始的數字:" << endl;
  8.                 cin >> x;
  9.                 int y;
  10.         cout << "輸入結束的數字:" << endl;
  11.         cin >> y;
  12.         int g = 0;
  13.         for ( int i = x; i <= y; i++ )
  14.         {
  15.         
  16.             g = g + i;        
  17.         }
  18.         cout << "總和:"<< g <<endl;
  19.         system ("pause");
  20.         return 0;
  21. }
複製代碼

TOP

返回列表