返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     int n=0,y,x,z;
  8.     cout << "請輸入要從幾開始加: ";
  9.     cin >> y;
  10.     cout << "請輸入要加到幾:";
  11.     cin >> x;
  12.     cout << "請輸入要每次要加幾: ";
  13.     cin >> z;
  14.     for(int i=y; i<=x; i=i+z)
  15.     {
  16.          n = n+i;
  17.     }
  18.     cout << y << "加到" << x << "的" << z <<"倍數總和為" << n << "\n";
  19.     goto re;   
  20.     system("pause");
  21.     return 0;
  22. }
複製代碼

TOP

返回列表