S2OJ/judger/uoj_judger/run/formatter.cpp

33 lines
676 B
C++
Raw Normal View History

#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') {
2016-07-18 16:39:37 +00:00
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();
2016-07-18 16:39:37 +00:00
}
putchar(c);
}
}
return 0;
}