> TEnt
Автор admin
Пятница, 12 июня 2009 11:32
> TEntry: typedef Thesaurus:iterator Titer; Объединение контейнеров STL 409 ostream& operator«(ostream& os.const TEntry& t){ os « t.first « “: “: copy(t.second.begin(). t.second.endO. ostream_iterator(os. ” “)): return os: } } // Генератор тестовых данных для тезауруса: class ThesaurusGen { static const string letters: static int count: public: int maxSizeO { return letters.size(): } TEntry operatorOO { TEntry result: if (count >- maxSizeO) count = 0: result.first – letters[count++]; int entries – (randO % 5) + 2; for(int i – 0: i < entries: i++) { int choice – randO % maxSizeO: char cbuf[2] = { 0 }: cbuf[0] – letters[choice]: result.second.push back(cbuf): } return result; } }: int ThesaurusGen::count – 0: const string ThesaurusGen::letters(“ABCDEFGHIJKL” “MNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”): // Запрос искомого “слова”: string menu(Thesaurus& thesaurus) { while(true) { cout « “Select a V’wordV. 0 to quit: “: for(TIter it = thesaurus.beginO; it !- thesaurus.endO: it++) cout « (*it).first « ‘ ‘; cout « endl; string reply; cin » reply: if(reply.at(0) — ‘0′) exit(0):
Комментарии закрыты.
Последние комментарии