快读快输模板
作者:互联网
1 #include "bits/stdc++.h" 2 using namespace std; 3 typedef long long ll; 4 inline ll read()//内联函数可以节省调用的开销,而且能够便于编译器和上下文配合做优化 5 { 6 ll s = 0,w = 1; 7 char ch = getchar(); 8 while(ch < '0' || ch > '9'){ 9 if(ch == '-') w = -1; 10 ch = getchar(); 11 } 12 while(ch >= '0' && ch <= '9'){ 13 s = (s << 1) + (s << 3) + (ch ^ 48);//== s * 10 + ch - '0';位运算快一点 14 ch = getchar(); 15 } 16 return s * w; 17 } 18 inline void write(ll x) 19 { 20 if(x < 0) putchar('-'),x = -x; 21 if(x > 9) write(x / 10); 22 putchar(x % 10 + '0'); 23 } 24 int main() 25 { 26 int k; 27 k = read(); 28 write(k); 29 }
标签:10,ch,int,ll,long,快输,快读,模板,getchar 来源: https://www.cnblogs.com/scannerkk/p/15843162.html