zoukankan      html  css  js  c++  java
  • 输入输出优化

    namespace IO{
    	const int maxn(1<<21|1);
    	char ibuf[maxn],*iS,*iT,obuf[maxn],*oS=obuf,*oT=obuf+maxn-1,_c,st[55];
    	int _f,tp;
    	char Getc(){
    		return (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,maxn,stdin),(iS==iT?EOF:*iS++)):*iS++);
    	}
    	void Flush(){
    		fwrite(obuf,1,oS-obuf,stdout);
    		oS=obuf;
    	}
    	void Putc(char x){
    		*oS++=x;
    		if(oS==oT)Flush();
    	}
    	template<class Int>void Input(Int &x){
    		for(_f=0,_c=Getc();_c<'0'||_c>'9';_c=Getc())_f=_c=='-';
    		for(x=0;_c<='9'&&_c>='0';_c=Getc())x=(x<<3)+(x<<1)+(_c^48);
    		if(_f)x=-x;
    	}
    	template<class Int>void Print(Int x){
    		if(!x)Putc('0');
    		if(x<0)Putc('-'),x=-x;
    		while(x)st[++tp]=x%10+'0',x/=10;
    		while(tp)Putc(st[tp--]);
    	}
    	void Getstr(char *s,int &l){
    		for(_c=Getc();_c<'a'||_c>'z';_c=Getc());
    		for(l=0;_c>='a'&&_c<='z';_c=Getc())s[l++]=_c;
    		s[l]=0;
    	}
    	void Putstr(const char *s){
    		for(int i=0,n=strlen(s);i<n;++i)Putc(s[i]);
    	}
    }
    
  • 相关阅读:
    validate BST
    LC282. Expression Add Operators
    nginx统计日志命令
    iptables和firewalld命令
    nginx安装
    测试服务器IO
    规范主机名和设置最大文件进程数
    Docker安装
    MySQL/MariaDB二进制安装
    Docker原理
  • 原文地址:https://www.cnblogs.com/ljq-despair/p/9677498.html
Copyright © 2011-2022 走看看