-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12416.cpp
More file actions
38 lines (37 loc) · 915 Bytes
/
12416.cpp
File metadata and controls
38 lines (37 loc) · 915 Bytes
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
#include <bits/stdc++.h>
const int max = 1000000;
int main() {
char a[max], b[max];
int i, j, k, l, last, count;
while (gets(a)) {
l = 0;
count = 1;
while (count != 0) {
count = 0;
last = 0;
j = 0;
for (i = 0; a[i] != '\0'; i++) {
if (a[i] == ' ') {
if (last == 0) {
last = 1;
b[j] = ' ';
j++;
}
else {
last = 0;
count = 1;
}
} else {
last = 0;
b[j] = a[i];
j++;
}
}
if (count == 1) l++;
b[j] = '\0';
strcpy(a, b);
}
printf("%d\n", l);
}
return 0;
}