返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     int k;
  8.     cout<<"請輸入第一個數: ";
  9.     cin>>k;
  10.    
  11.     int i;
  12.     cout<<"請輸入第二個數: ";
  13.     cin>>i;
  14.    
  15.     int sum=0;
  16.    
  17.    
  18.     {
  19.         for(int f=k; f<=i; f++)
  20.         sum+=f;
  21.         {
  22.    
  23.             cout<<"從"<<k<<"到"<<i<<"所有整數的總和為: "<<sum<<endl;
  24.    
  25.         }
  26.     }  
  27.     cout<<endl;
  28.     goto re;  
  29.     system("pause");
  30.     return 0;
  31.    
  32. }
複製代碼

TOP

返回列表