-
Notifications
You must be signed in to change notification settings - Fork 6
/
1101.c
51 lines (28 loc) · 894 Bytes
/
1101.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
int main(){
int i, N, M, soma = 0;
scanf("%d %d", &M, &N);
while(M != 0 && N != 0 && M > 0 && N > 0){
soma = 0;
if(M > N){
for(i = N; i <= M; i++){
printf("%d ", i);
soma = soma + i;
}
printf("Sum=%d\n", soma);
soma = 0;
}
else if(N > M){
for(i = M; i <= N; i++){
printf("%d ", i);
soma = soma + i;
}
printf("Sum=%d\n", soma);
}
else{
printf("%d Sum=%d\n", M, M);
}
scanf("%d %d", &M, &N);
}
return 0;
}