// CSE 143 Au00 Hw1 Sample Solution // HP 9/00 // wordlist.h - Interface to word/frequency data & operations const int MAX_WORDS = 300; // Max # distinct words in list struct WordInfo { // information about a single word string word; // the word itself int frequency; // # of times it has appeared so far }; struct WordList { // list of words and frequencies WordInfo entry[MAX_WORDS]; // Word/frequency pairs are stored int nWords; // in entry[0..nWords-1] }; // Set w to empty void make_empty(WordList &w); // If word s is in list w, increase its frequency by 1, // otherwise add it to w with a frequency of 1. void count_word(string s, WordList &w); // Sort entries in w in descending order by word frequencies. // If two words have the same frequency, place them in alphabetical order void sort_words(WordList &w); // Print on cout the first n entries in w, or all entries if n > w.nWords void print_n_words(int n, WordList &w);