写这篇博客不为什么,就是是为了纪念一下我复杂得心情!!!
以下的图片都是来自同一个水题!!!
scanf和cin+ios::sync_with_stdio(false)输入
cin+ios::sync_with_stdio(false)+cin.tie(0)+cout.tie(0)输入;
快读输入
快读+快写
在这里给大家找了一个相对快的快读,见下面。
(如果与哪位老兄的冲突了,还请见谅,当时打开博客太多了,然后全都直接关了,忘了复制链接了…)
#include <bits/stdc++.h>
using namespace std;
//快读
inline int read() {
int num=0, w=0;
char ch=0;
while (!isdigit(ch)) {
w|=ch=='-';
ch = getchar();
}
while (isdigit(ch)) {
num = (num<<3) + (num<<1) + (ch^48);
ch = getchar();
}
return w? -num: num;
}
//快写
inline void write(int x)
{
if(x<0) {
putchar('-');
x = -x;
}
if(x>9) write(x / 10);
putchar(x % 10 + '0');
}
int main(){
int a;
a = read(); //读入到t中
write(t); //输出t
putchar('\n');
}
下面这个是浮点数的
inline bool scan_lf(double &num)
{
char in;double Dec=0.1;
bool IsN=false,IsD=false;
in=getchar();
if(in==EOF) return false;
while(in!='-'&&in!='.'&&(in<'0'||in>'9'))
in=getchar();
if(in=='-'){IsN=true;num=0;}
else if(in=='.'){IsD=true;num=0;}
else num=in-'0';
if(!IsD){
while(in=getchar(),in>='0'&&in<='9'){
num*=10;num+=in-'0';}
}
if(in!='.'){
if(IsN) num=-num;
return true;
}else{
while(in=getchar(),in>='0'&&in<='9'){
num+=Dec*(in-'0');Dec*=0.1;
}
}
if(IsN) num=-num;
return true;
}