-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathp405.c
36 lines (35 loc) · 774 Bytes
/
p405.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
/* Imprimiendo páginas sueltas */
#include <stdio.h>
int main() {
int a, b, rango, inicio;
while(1) {
scanf("%d", &a);
if(a == 0)
break;
inicio = a;
rango = 0;
while(1) {
scanf("%d", &b);
if(b == 0) {
break;
}
if(b == a+1) {
rango = 1;
} else {
if(rango)
printf("%d-%d,", inicio, a);
else
printf("%d,", a);
inicio = b;
rango = 0;
}
a = b;
}
if(rango)
printf("%d-%d", inicio, a);
else
printf("%d", a);
printf("\n");
}
return 0;
}