示例#1
0
/******************************************************************************
purpose: prints a Frequency Table built from the maketable() function, this
          function first prints out the frequency of each word in the list,
          followed by the word in alphabetical order.
input: a table of class FrequencyTable
returns: n/a
*****************************************************************************/
void print(FrequencyTable table)
{
  int size = table.size();
  string word;
  int freq;

  for(int i = 0; i < size; i++){
    table.get(i, &word, &freq);//gets pointers to the Nodes
    cout << freq << " " << word << endl;
  }
}
示例#2
0
void print_words(FrequencyTable mytable)
{
  for (int n = 0; n < mytable.size(); n++) {
    int *p_freq = new int;
    string *p_word = new string;
    mytable.get(n, p_word, p_freq);
    cout << *p_freq << " " << *p_word << endl;
    delete p_freq;
    delete p_word;
  }
}