工程上还是使用string算了(
调整好码风写好注释,要有个工程代码的样!
Visual Studio断点调试:https://blog.csdn.net/lindexi_gd/article/details/102831108
cmd fc使用:https://blog.csdn.net/cnsecs/article/details/9039101
string使用:https://blog.csdn.net/liitdar/article/details/80498634
map与unordered_map:https://blog.csdn.net/u013288190/article/details/121018747
unordered_map:https://www.cnblogs.com/langyao/p/8823092.html
结构体内不改变结构体内部的成员都要加上const(会快很多,重载括号后的代表重载不改变结构体)
set构造时重载运算符要写成struct cmp
struct cmp {
const bool operator()(const int a, const int b)const {
return team_[a] < team_[b];
}
};不让使用using namespace std;,防止工程时出现一些重名问题等
“有关using编译命令和using声明,需要记住的一点是,他们 增加了名称冲突的可能性。”
对于c里面本身就有的东西都不需要using
但是对于一些c++新增的东西,比如string,set,vector等等结构都是需要使用using的,或者是在使用的时候添加std::
using std::vector;
using std::string;
using std::set;
using std::unordered_map;快读快输板子
char buffer[32];
char* top;
inline bool judge(const char& x) {
return x == EOF || x == ' ' || x == '\n' || x == '\0';
}
inline void CharRead(char& x) {
while (judge(x = getchar()));
}
inline void WriteChar(const char* p) {
while (*p != '\0')
putchar(*(p++));
}
inline void IntRead(int& x) {
int f = 1; char s = getchar(); x = 0;
while (!isdigit(s)) { if (s == '-')f = -1; s = getchar(); }
while (isdigit(s)) { x = (x << 1) + (x << 3) + (s ^ 48), s = getchar(); }
x *= f;
}
inline void IntWrite(int x) {
if (!x) putchar('0');
else {
if (x < 0) {
putchar('-'), x = -x;
}
top = buffer;
while (x) {
(*top) = (x % 10) ^ '0';
x /= 10; ++top;
}
while (top != buffer) putchar(*(--top));
}
}
inline void ReadString(string &str){
str.clear();
char s = getchar();
while (s == ' ' || s == '\n' || s == '\r') s = getchar();
while (s != ' ' && s != '\n' && s != '\r' && s != EOF) {
str += s;
s = getchar();
}
}使用统一的buffer可以极大优化现开新数组的消耗
码风提示:不要使用define定义常数,const是用来干嘛的(恼)
set<int,cmp> st STL注册时中间要有空格
使用op而非opt作为变量名
建议每次工程代码从头写,不要像OI题一样粘板子,头文件用的时候再写,不要using namespace std;