- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- int a=0,b=0,c=0;
- cout<<"input the first number: ";
- cin>>a;
- cout<<"input the second number: ";
- cin>>b;
- if(a<=b){
- for(;a<=b;a++)
- {
- c=c+a;
- }
- }
- else if(b<=a){
- for(;b<=a;b++)
- {
- c=c+b;
- }
- }
- cout<<"the sum of all the numbers between them is "<<c<<"\n\n";
- goto re;
- system("pause");
- return 0;
- }
複製代碼 |