cyc's Code Style

所有头文件必须写在最开头,不应该使用""而该使用<>

#include<>之间需要有空格

注:非必要不使用#include <bits/stdc++.h>

Example:

1
2
3

#include <iostream>


可以使用using namespace std;也可以在具体代码中写入std::


关于大括号,若if/for/while等语句,在其内容中只有一行的,不应加大括号,使用空格分开

在必须加入大括号时,左括号不换行,有括号换行

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14

int main(){
while(l<r){
l++,r--;
if(l<=m) Ans++;
else Cnt--;
if(r>s){
Flag=true;
Ans--;
}
}
return 0;
}


关于空格的添加,非必要不添加空格在表达式中


命名:函数命名使用驼峰命名和类匈牙利命名法,变量视情况而定,在名称仅有1~2个字符时除外


关于输入输出,在输入过于复杂时在main函数外新建void类函数Input,用于输入,输出同理

在必须时使用scanf和printf,否则使用cin和cout

尽量使用cin.tie(0);cout.tie(0)而不使用ios::sync_with_stdio(false);

在使用快速输入时和快速输出时尽量都使用快速输入时和快速输出函数,而不是其他的输入输出方式


Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

#include <iostream>
#include <cstring>
using namespace std;
struct Node{
string s1,s2;
int itr;
};
int longa;
Node a;
inline int Read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}

void Write(int x){
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
return ;
}

int main(){
read(longa);
cin>>a.s1>>a.s2;
read(a.itr);
if(a.itr>0) puts("I AK IOI\n");
else write(a.s1);
write(a.s2);
return 0;
}


本博客所有文章除特别声明外,均采用 CC BY-NC 4.0 协议 ,转载请注明出处!