返回列表 發帖
本帖最後由 李允軒 於 2014-3-29 13:58 編輯
  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.         int k = 0;
  13.         for (int l = i; l <= j; l++)
  14.         {
  15.                 k = k + l;
  16.         }
  17.         cout << "答案:" << k <<endl;
  18.     system("pause");
  19.     return 0;

  20. }
複製代碼

TOP

返回列表