-
fread 读入
有莫名其妙的问题,一般不用
1 inline char nc(){ 2 static char buf[100000],*p1=buf,*p2=buf; 3 return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++; 4 } 5 inline int read(){ 6 char ch=nc();int sum=0; 7 while(!(ch>='0'&&ch<='9'))ch=nc(); 8 while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc(); 9 return sum; 10 }
-
getc(stdio) 读入
用的最多
inline void read(int &x) { x = 0;int f = 1;char ch; ch = getc(stdin); while(ch > '9'||ch < '0') {if(ch == '-') f = -1;ch = getc(stdin);} while(ch <= '9'&&ch >= '0') {x = (x * 10) + (ch ^ 48);ch = getc(stdin);} x *= f; }