[OI

qwq算是一个板子随笔吧

快读我在某大佬的博客中找到了更短的代码

但是这个写习惯了就改不了了qwq

其实是我不想改

废话好多

直接贴代码

 1 //读入优化 
 2 inline int read(){
 3     char ch, c;
 4     int res;
 5     while (ch = getchar(), ch < '0' || ch > '9') c = ch;
 6     res = ch - 48;
 7     while (ch = getchar(), ch >= '0' && ch <= '9')
 8     res = (res << 3) + (res << 1) + ch - 48;
 9     if (c == '-') res = -res;
10     return res;
11 }
12 //输出优化
13 void write(int x){
14     if (x < 0) putchar('-'), x = -x;
15     if (x > 9) write(x / 10);
16     putchar(x % 10 + '0');
17     return;
18 } 

然后在使用的时候

1 int main(){
2     int n;
3     n = read();
4     write(n);
5 }

注意别忘了头文件名

#include <cstdio>

不许说我大括号不换行差评

原文地址:https://www.cnblogs.com/aiyi2000/p/9419025.html