頭文件

常見頭文件

#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;

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、字符串操作 strcpy(p, p1) 復(fù)制字符串 strncpy(p, p1, n) 復(fù)制指定長度字符串 s...
    JaiUnChat閱讀 1,752評論 0 7
  • 本文轉(zhuǎn)自:http://www.cnblogs.com/lidabo/p/5225868.html 1)字符串操作...
    XiaohuiLI閱讀 9,688評論 0 0
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,661評論 19 139
  • 在c語言中,字符串是用字符數(shù)組來存儲的(并不像c++或者java等語言中有單獨(dú)的string類型), 存放時在字符...
    朱森閱讀 1,694評論 0 2
  • (一) 想起敦煌小鎮(zhèn),總會讓人想到那首經(jīng)典的老歌,總會讓人想起熟悉的普洱茶,總會讓人想起那個從人間煙火中走出來的含...
    東方地秀閱讀 625評論 42 30

友情鏈接更多精彩內(nèi)容