C++快速读入输出

void read(int &x) {
	int f = 1;
	x = 0;
	char op = getchar();
	while(op < '0' || op > '9') { 
		if(op == '-') f = -1;
		op = getchar();
	}
	while(op >= '0' && op <= '9') {
		x = x * 10 + op - '0';
		op = getchar();
	}
	x *= f;
}
void print(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

 

你可能感兴趣的:(c/c++)