常見頭文件
#include 《cstdio>
#include 《cmath>
http://www.cplusplus.com/reference/cmath/
#include 《algorithm>
http://blog.csdn.net/wlchen123/article/details/8219131
常見的:max、min、sort 、swap、
#include 《iostream>
#include 《cstring>
http://www.cnblogs.com/xFreedom/archive/2011/05/16/2048037.html
C++里的 cstring對應(yīng)C語言的string.h
string.h是C中處理字符串的函數(shù)的聲明,string是C++中string類的頭文件,盡管在C++中包含string.h是允許的,但C++標(biāo)準(zhǔn)建議用頭文件cstring來替代string.h
里面常用:
strcmp(a,b)==0? 比較字符串是否相同,相同返回值是0,a>b返回正數(shù);a《b返回負(fù)數(shù)
memset(a,0,sizeof(a));? ? ? 把字符串清空(所有字符元素全變成\0)
strlen(a);? ? ? ? ? 計(jì)算這個字符串的長度(到第一個\0為止)
strcpy
strcat:char * strncat ( char * destination, const char * source, size_t num );
Append characters from string
Appends the firstnumcharacters ofsourcetodestination, plus a terminating null-character.
If the length of the C string insourceis less thannum, only the content up to the terminating null-character is copied.
size()
length()
reverse()
substr() ?string substr (size_t pos = 0, size_t len = npos) const;
find()? 若查找成功,返回按查找規(guī)則找到的第一個字符或子串的位置;若查找失敗,返回npos,即-1(打印出來為4294967295)
#include 《map>
#include 《string>
C++中,string頭文件基本上已經(jīng)包含在iostream中了。
但是,平時使用的時候建議加上#include(尤其在以下情況下)
1、使用string類型
2、使用cin、cout語句來輸入輸出string類型變量(注意,同時還需要#include)
3、使用memset()、strlen()、strcpy()、strcat等函數(shù)時
函數(shù)原型char *strcpy(char *dest,const char *src)
#include 《stack>
#include 《cctype>
#include 《vector>
#include 《queue>
#include 《set>
#include 《utility>
#include 《cassert>
#include 《numeric>
#include 《sstream>
using?namespace?std;
#define?Online_Judge
#define?outstars?cout?<<?"***********************"?<<?endl;
#define?clr(a,b)?memset(a,b,sizeof(a))
#define?lson?l?,?mid??,?rt?<<?1
#define?rson?mid?+?1?,?r?,?rt?<<?1?|?1
#define?mk?make_pair
const?int?MAXN?=?1000?+?50;
const?int?MAXS?=?10000?+?50;
const?int?sigma_size?=?26;
const?long?long?LLMAX?=?0x7fffffffffffffffLL;
const?long?long?LLMIN?=?0x8000000000000000LL;
const?int?INF?=?0x7fffffff;
const?int?IMIN?=?0x80000000;
const?int?inf?=?1?<<?30;
#define?eps?1e-10
const?long?long?MOD?=?1000000000?+?7;
const?int?mod?=?10007;
typedef?long?long?LL;
const?double?PI?=?acos(-1.0);
typedef?double?D;
typedef?pair?pii;
typedef?vector?vec;
typedef?vector?mat;
typedef?vector?vs;