I/O 优化

数字的读入优化:

/* I/O
 * Au: GG
 */

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

int read() {
	int sum = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c))
		sum = sum * 10 + c - '0', c = getchar();
	return sum;
}
void write(int num) {
	if (!num) putchar('0');
	else {
		stack<int> st;
		while (num > 0)
			st.push((char) (num % 10 + '0')),
			num /= 10;
		while (!st.empty())
			putchar((char) (st.top())),
			st.pop();
	}
}
void writeln(int num) {write(num); putchar('\n');}

int main() {
	for (int i = 1; i <= 5; i++) {
		int j = read();
		writeln(j);
	}
	return 0;
}
posted @ 2017-09-20 10:40  greyqz  阅读(158)  评论(0编辑  收藏  举报