|
Thinking In C++. Volume 2: Practical Programmingos,const TEntry& t){ В os << t.first << ": "; В copy(t.second.begin(), t.second.end(), В В В ostream_iterator<string>(os, " ")); В return os; } // A generator for thesaurus test entries: class ThesaurusGen { В static const string letters; В static int count; public: В int maxSize() { return letters.size(); } В ThesaurusGen() { srand(time(0)); } В TEntry operator()() { В В В TEntry result; В В В if(count >= maxSize()) count = 0; В В В result.first = letters[count++]; В В В int entries = (rand() % 5) + 2; В В В for(int i = 0; i < entries; i++) { В В В В В int choice = rand() % maxSize(); В В В В В 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"); // Ask for a "word" to look up: string menu(Thesaurus& thesaurus) { В while(true) { В В В cout << "Select ...» | Код для вставки книги в блог HTML
phpBB
текст
|
|