Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int i, m, n;
- for (i=0; m>0 || n>0; ++i)
- {
- int j, sum=0;
- scanf("%d %d", &m, &n);
- if (m<=0 || n<=0) break;
- if (m>n)
- {
- for (j=n; j<=m; ++j)
- {
- printf("%d ", j);
- sum+=j;
- }
- printf("Sum=%d\n", sum);
- }
- if (m<n)
- {
- for (j=m; j<=n; ++j)
- {
- printf("%d ", j);
- sum+=j;
- }
- printf("Sum=%d\n", sum);
- }
- if (m==n)
- {
- for (j=m; j<=n; ++j)
- {
- printf("%d ", j);
- sum+=j;
- }
- printf("Sum=%d\n", sum);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement