set和multiset小練習

2021-10-23 10:12:11 字數 1929 閱讀 8640

// set容器小練習.cpp : 此檔案包含 "main" 函式。程式執行將在此處開始並結束。

// 題目:

#include #include #include #include using namespace std;

struct calltable

; void calltable_init(const string name, const long phonenumber)

calltable(const string name, const long phonenumber)

operator const char*()

bool operator == (const calltable &table) const

bool operator == (const string &name) const

bool operator == (const long &phonenumber) const

bool operator > (const calltable &table) const

bool operator < (const calltable &table) const

friend ostream& operator <<(ostream& output, const calltable& table);

};ostream& operator <<(ostream& output, const calltable& table)

struct defaultdescendorder

};void question1()

itor1 = table.cbegin();

if (mode == 1)

else if (mode == 2)

else

}else if (mode == 3)

else

}else if (mode == 4)

else

} else if (mode == 5)

else

}else if (mode == 6)

}}struct dictionary

; dictionary(string word, string explanation)

void dictionary_init(string word, string explanation)

bool operator == (const string &word) const

operator const char*()

bool operator < (const dictionary& dictionary) const

friend ostream& operator << (ostream& output, dictionary& dic);

};ostream& operator << (ostream& output, const dictionary& dic)

struct defaultascendorder

};/*模式選擇;

mode=1為讀取模式;

mode=2為錄入資料模式;

mode=3為刪除資料模式;

mode=4為退出字典模式;*/

void question2()

; multiset::iterator itor1;

string word;

string explanation;

int mode = 0;

while (1)

if (mode == 1)

else

}else if (mode == 2)

else if (mode == 3)

else

}else if (mode == 4)

}}int main()

set和multiset容器簡介

set和multiset容器簡介 開發工具與關鍵技術 c visualstudioset 是乙個集合容器,其中所包含的元素是唯一的,集合中的元素按一定的順序排列。它其他的 容器不同,它是不能指定位置插入的,它的元素插入過程是按排序規則插入的。set雖然不能指定位置插入,但是在插入和刪除操作較快,因為...

STL之set和multiset總結

set c 建立空集合,不包含任何元素 set c op 以op為排序準則,產生乙個空的set set c1 c2 複製c2中的元素到c1中 set c const value type first,const value type last 複製 first,last 之間元素構成新集合 set ...

STL詳解之set和multiset

set 裡面的元素不能重複,自動排序 multiset 裡面的元素自動排序,可以有重複的。include using namespace std include include void f1 不取最後一位的反斜槓0 vectorvec ia,ia 10 setiset vec.begin vec....