fread()的板子

#include<cstdio>
int a,b;
char *ch;
inline void read(int &x){
	x=0;int f=0;
	while(*ch!='-'&&(*ch<'0'||*ch>'9'))++ch;
	if(*ch=='-')f=1,++ch;
	while(*ch>='0'&&*ch<='9')x=(x<<1)+(x<<3)+*ch-48,++ch;
	f?x*=-1:x;
}
int main(){
	freopen("test.in","r",stdin);
	fseek(stdin,0l,SEEK_END);
	int flen=ftell(stdin);
	fseek(stdin,0l,SEEK_SET);
	char *buffer = new char [flen+1];
	fread(buffer,1,flen,stdin);
	ch=buffer;
    read(a);
    read(b);
	printf("%d\n",a+b);
    return 0;
}

  

 

posted @ 2017-10-25 21:47  Stump  阅读(233)  评论(0编辑  收藏  举报