Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,m;
- while(1)
- {
- cin>>n>>m;
- if(n<=0||m<=0)
- break;
- if(m>n)
- {
- int s=0;
- for(int i=n;i<=m;i++)
- {
- cout<<i<<" ";
- s=s+i;
- }
- cout<<"sum ="<<s;
- cout<<endl;
- }
- if(n>m)
- {
- int k=0;
- for(int j=m;j<=n;j++)
- {
- cout<<j<<" ";
- k=k+j;
- }
- cout<<"sum ="<<k;
- cout<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement