Interesting skills about c++
Erina
·
·
个人记录
Some interesting skills about c++
这是一篇英文文章
How to write for faster?
#define f(i,j,k) for(int i=(j);i<(k);i++)
#define rf(i,j,k) for(int i=(j);i>(k);i--)
speed up:
#define f(i,j,k) for(register int i=(j);i<(k);i++)
#define rf(i,j,k) for(register int i=(j);i>(k);i--)
How to read FASTER
speed reading reads faster,even in reading documents
ios::sync_with_stdio(false);//maybe CE
int read(){//read one integer
int num=0,w=1;char ch=getchar();
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
num=num*10+ch-48;
ch=getchar();
}
return num*w;
}
double readd(){//read one double
double num;int w=1;double plus=1;
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
num=num*10+ch-48;
ch=getchar();
}
if(ch=='.'){
ch=getchar();
while(isdigit(ch)){
plus/=10;
num+=(ch-48)*plus;
}
}
return num*w;
}
int readsp(){
int num=0,w=1;char ch=getchar();
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
num=num*10+ch-48;
if(cin.peek()='\n')break;
ch=getchar();
}
return num*w;
}
int RLI(int*sp){//read a line of integer
int i=0;
while(cin.peek()!='\n'){
*sp=readsp();
sp++,i++;
}
}
char gc(){
static char bb[1000000],*s=bb,*t=bb;
return s==t&&(t=(s=bb)+fread(bb,1,1000000,stdin),s==t)?EOF:*s++;
}
How to curse someone in a friendly way?
#define fuck return
#define you 0
int main(){
fuck you;
}
Switch a string to a integer
int Switch(string s){
int num=0;
for(int i=0;i<s.length();i++){
num=num*10+s[i]-48;
}
return num;
}
Use overflow to AC A+B
#include<iostream>
using namespace std;
int main(){
int A[10],a,b;
cin>>a>>b;
cout<<A[10]+A[11];
}