ls学习笔记note39:关于输入&输出
paperghost_ls
·
·
个人记录
众所周知,LS是一个大vegetable chicken,以至于TA连输入输出都要纠结很久
因此诞生了这一篇非常奇怪和看起来就很智障的东西
(这段废话貌似已经浪费了屏幕前的$dalao$您几$0.00000000000000001$秒时间了...)
那么,就让我们来看看这个~~SB~~究竟找了些什么~~垃圾~~东西吧:
### 快速读入&输出:
[搬运链接](https://www.luogu.com.cn/paste/a167io07)
```
//快速读入&输出模板
inline int read()
{
char ch=getchar();int x=0,f=1;
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=x*10+ch-'0';
ch=getchar();
}
return f*x;
}
inline void write(int x)
{
if(x<0)x=~x+1,putchar('-');
if(x>9)write(x/10);
putchar(x%10+'0');
}
```
update:2020.3.21
我来填坑了
发现WGN大佬用的快读和我的有些许不同,应该会快一些,学学吧
```
inline int read()
{
char ch=getchar();int x=0,f=1;
while(!isdigit(ch))//检查一个数是不是十进制数字字符,不是的话返回0,是的话返回非0数
{
if(ch=='-')f=-1;
ch=getchar();
}
while(isdigit(ch))
{
x=x*10+(ch&15)
ch=getchar();
}
return f*x;
}
```
用了这个isdigit函数就要使用#include<cctype>这个头文件
### 将一串连起来的数读入时存入数组:
```
#include<cstdio>
using namespace std;
int n;//该数的位数
int a[10];
int main()
{
scanf("%d",&n);
for(ri i=1;i<=n;i++)scanf("%1d",&a[i]);
return 0;
}
```
# 未完待续...