返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         re:
  7.         int a=0,b=0,c=0;
  8.         cout<<"input the first number: ";
  9.         cin>>a;
  10.         cout<<"input the second number: ";
  11.         cin>>b;
  12.         if(a<=b){
  13.         for(;a<=b;a++)
  14.         {
  15.                 c=c+a;
  16.         }
  17.         }
  18.         else if(b<=a){
  19.         for(;b<=a;b++)
  20.         {
  21.                 c=c+b;
  22.         }
  23.         }
  24.         cout<<"the sum of all the numbers between them is "<<c<<"\n\n";
  25.         goto re;
  26. system("pause");
  27. return 0;
  28. }
複製代碼

TOP

返回列表