码迷,mamicode.com
首页 > 其他好文 > 详细

fread()的板子

时间:2017-10-25 23:48:27      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:++   sharp   read   ret   printf   turn   stdin   logs   ==   

#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;
}

  

 

fread()的板子

标签:++   sharp   read   ret   printf   turn   stdin   logs   ==   

原文地址:http://www.cnblogs.com/Stump/p/7732578.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!