mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-25 21:58:41 +00:00
33 lines
676 B
C++
33 lines
676 B
C++
#include <cstdio>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <string>
|
|
|
|
int main() {
|
|
int c = '?', last;
|
|
std::string buf;
|
|
while (true) {
|
|
last = c;
|
|
c = getchar();
|
|
if (c == EOF) {
|
|
if (last != '\n') {
|
|
putchar('\n');
|
|
}
|
|
break;
|
|
} else if (c == ' ' || c == '\r') {
|
|
buf.push_back((char)c);
|
|
} else {
|
|
if (!buf.empty()) {
|
|
if (c != '\n') {
|
|
printf("%s", buf.c_str());
|
|
}
|
|
buf.clear();
|
|
}
|
|
putchar(c);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|