OSDN Git Service

Update io.md
authoryizr-cnyali <yizr_cnyali@qq.com>
Fri, 1 Mar 2019 06:45:20 +0000 (14:45 +0800)
committerGitHub <noreply@github.com>
Fri, 1 Mar 2019 06:45:20 +0000 (14:45 +0800)
重新定义了变量ch以提高速度

docs/misc/io.md

index 2154cb3..5a5ed57 100644 (file)
@@ -193,7 +193,8 @@ inline void write(int x) {
 
 ```cpp
 template <typename T> inline T read(){ //声明 template 类,要求提供输入的类型T,并以此类型定义内联函数 read()
-    T sum=0,fl=1,ch=getchar();//将 sum,fl 和 ch 以输入的类型定义
+    T sum=0,fl=1;//将 sum,fl 和 ch 以输入的类型定义
+    int ch=getchar();
     for(;!isdigit(ch);ch=getchar()) if(ch=='-') fl=-1;
     for(;isdigit(ch);ch=getchar()) sum=(sum<<3)+(sum<<1)+ch-'0';
     return sum*fl;