TAILIEUCHUNG - Thinking in C plus plus (P24)

Tham khảo tài liệu 'thinking in c plus plus (p24)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | A map of vectors include map include vector include string include iostream include algorithm include ctime using namespace std typedef map string vector string Thesaurus typedef pair string vector string TEntry typedef Thesaurus iterator TIter ostream operator ostream os const TEntry t os copy 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 ThesaurusGen srand time 0 TEntry operator TEntry result if count maxSize count 0 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 cbuf return result int ThesaurusGen count 0 Chapter 15 Multiple Inheritance 251 const string ThesaurusGen letters ABCDEFGHIJKL MNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz int main Thesaurus thesaurus Fill with 10 entries generate_n inserter thesaurus 10 ThesaurusGen Print everything copy ostream_iterator TEntry cout n Ask for a word to look up while true cout Select a word 0 to quit for TIter it it it cout it .first cout endl string reply cin reply if 0 0 return 0 Quit if reply continue Not in list try again vector string v thesaurus reply copy ostream_iterator string cout cout endl A Thesaurus maps a string the word to a vector string the synonyms . A TEntry is a single entry in a Thesaurus. By creating an ostream operator for a TEntry a single entry from the Thesaurus can easily be printed and the whole Thesaurus can easily be printed with copy . The ThesaurusGen creates words which are just single letters and synonyms for those words which are just other randomly-chosen single letters to be used as thesaurus entries. It randomly chooses the number of synonym entries to make but there must be at least two.

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.