快速输入输出模板

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');
}

 

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int buf[40];

template<class T> inline bool getd(T& x){
    int ch=getchar();
    bool neg=false;
    while(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');
}

void init()
{
    
}

void work()
{
    
}

int main()
{
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
    #endif
    init();
    work();
    return 0;
}

 

posted @ 2016-12-11 10:47  清羽晨风  阅读(1176)  评论(0编辑  收藏  举报