劉汝佳第五章 UVA 10391

2021-09-30 16:30:07 字數 597 閱讀 8437

這個題,學習了很多關於迭代器和string的知識。。。

對於集合set

建立迭代器用格式 set::iterator it; 目前不是很清楚雙冒號什麼用。

set.find()函式,如果找到,返回此處的迭代器,如果找不到,返回set.end

set.insert(x),在集合中插入x

對於string

流式輸入cin>>string

string.c_str 返回乙個處理後的臨時指標,指向乙個str陣列

string.substr (begin,length) 如果不加length,那麼是從頭到尾

string.substring (begin,end) 和前面的substr有點不一樣

string.length() 基本操作

#includeusing namespace std;

setwords;

int main(void)

set::iterator it;

for (it=words.begin();it!=words.end();it++)}}

return 0;

}

劉汝佳第五章 UVa 12096

include include include include include include includeusing namespace std define ins x inserter x,x.begin define all x x.begin x.end typedef setset m...

劉汝佳第五章UVA 230

這道題對於不熟悉基本操作 尤其是string 的我來說,實在是太難了。先總結一下基本操作 結構體內重構操作符 bool operater 可以讓結構體可以比較大小。string.find a,num 是從string的第num開始找a,並且返回a的位置,如果找不到,則返回string nops st...

筆記 第五章(上)劉汝佳 演算法競賽入門經典

void swap2 int a,int b 表示傳引用 intmain 例 知識點解說詳見 p106 struct point 建構函式,特點 沒有返回值 引數中的0是預設值,沒有指明引數時相當於呼叫 point 0,0 來構造 x x 是簡化寫法,等同於 this x x point a,b 1...