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

快速输入输出模板

时间:2016-12-11 12:34:52      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:csharp   tchar   put   for   arp   pre   log   nbsp   blog   

template<class T> inline bool getd(T& x)
{
	int ch=getchar();
	bool neg=false;
	if(ch!=EOF && ch!=‘-‘ && !isdigit(ch)) ch=getchar();
	if(ch==EOF) return false;
	if(ch==‘-‘){
		neg=true;
		ch=getchar();
	}
	x=ch-‘0‘;
	while(isdigit(ch=getchar())) x=x*10+ch-‘0‘;
	if(neg) x=-x;
	return true;
}

template<class M> inline void putd(M x)
{
	int p=0;
	if(x<0){
		putchar(‘-‘);
		x=-x;
	}
	do{
		buf[p++]=x%10;
		x/=10;
	}while(x);
	for(int i=p-1;i>=0;i--) putchar(buf[i]+‘0‘);
	putchar(‘\n‘);
}

 

快速输入输出模板

标签:csharp   tchar   put   for   arp   pre   log   nbsp   blog   

原文地址:http://www.cnblogs.com/tsingyawn/p/6159191.html

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