时间
求月份中有多少天
bool isleap(int year){ if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return true; else return false;}int Dayofmonth(int year, int month){ return 31 - ((month == 2) ? (3 - isleap(year)) : ((month - 1) % 7 % 2));}
字符串
int 转 string
void int_into_string(int val, string &str_val) { string tmp; while (val) { tmp += val % 10 + '0'; val = val / 10; } for (int i = tmp.length(); i >= 0; i++) { str_val += tmp[i]; } str_val += "#";}
string 转 int
void string_into_int(string str, vector<int> &num) { int val = 0; for (int i = 0; i < str.length(); ++i) { if (str[i] == '#') { num.push_back(val); val = 0; } else { val = val * 10 + str[i] - '0'; } }}
重载运算符
friend complex operator+(const complex & A, const complex & B);friend complex operator-(const complex & A, const complex & B);friend complex operator*(const complex & A, const complex & B);friend complex operator/(const complex & A, const complex & B);friend istream & operator>>(istream & in, complex & A);friend ostream & operator<<(ostream & out, complex & A);