读入优化&&输出优化

#include
int isdigit[300];

void read(int &x)
{
	int f = 1; x = 0; char s = getchar();
	while(!isdigit[s]) {if(x == '-') f = -1; s = getchar();}
	while(isdigit[s]) {x = x*10 + s-'0'; s = getchar();}
	x *= f;
}

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

int main()
{
	for(int i = '0'; i <= '9'; i++) isdigit[i] = 1;
}

你可能感兴趣的:(玄学优化)