C++ 快读快写模板

快读模板

int read() {
	int x = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-')
			w = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * w;
}

快写模板

void write(int x) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}

给个赞吧!

posted @ 2023-02-14 09:50  煎饼Li  阅读(27)  评论(0编辑  收藏  举报