STL標準庫函式總結

2021-08-21 22:26:58 字數 589 閱讀 7956

平時stl自己用的很少,很多庫函式都不是很熟悉,趁著最近有空,將stl的知識學習一下。主要學習一下,pair,vector,set,vector,stack,queue,map,string.

位於標頭檔案< iostream>中用來表示乙個二元組或元素對

1.1 使用pair

定義乙個pair物件表示乙個平面面座標點:

pair<

double

,double

> p;

cin >> p.first >> p.second;

2.1排序

int

cmp(pair<

int,

int> a,pair<

int,

int> b)

stl vector

stl set

stl map

stl queue and priority_queue

stl stack

stl lower_bound upper_bound and binary_search

常用標準I O庫函式總結

1 fopen fopen 函式主要用於對檔案和終端的輸入輸出。但是如果要對裝置的行為進行更為明確的行為控制,那最好使用底層系統呼叫,因為這樣可以避免庫函式帶來的一些非預期的潛在 函式原型 include file fopen const char filename,const char mode ...

C語言標準庫函式總結

一.動態記憶體分配 1.malloc 原型 extern void malloc unsigned int num bytes 用法 include 功能 分配長度為num bytes位元組的記憶體塊 說明 如果分配成功則返回指向被分配記憶體的指標,否則返回空指標null。當記憶體不再使用時,應使用...

STL 常見庫函式

stack void push const t value 向棧頂插入乙個元素 void pop 移除棧頂元素 bool empty const 檢查棧是否為空 size type size const 返回棧中元素的數量 reference top const reference top cons...