Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lin Chen 09/13/2011. Count words number in the file arrayUtils.h include the adding functions template int addInOrder (T* array, int& size, T value);

Similar presentations


Presentation on theme: "Lin Chen 09/13/2011. Count words number in the file arrayUtils.h include the adding functions template int addInOrder (T* array, int& size, T value);"— Presentation transcript:

1 Lin Chen 09/13/2011

2 Count words number in the file arrayUtils.h include the adding functions template int addInOrder (T* array, int& size, T value); template int seqOrderedSearch(const T list[], int listLength, T searchItem) template int binarySearch(const T list[], int listLength, T searchItem) wordcount.cpp string reduceWords (string word); void histogram(const int MaxWords, istream& input, ostream& output); int main (int argc, char** argv); test0.in lglass18.txt

3 Modify function void histogram(const int MaxWords, istream& input, ostream& output); //* Declare an array of strings to hold all words //* and an array of int to hold the number of times each word //* encountered. //* Reduce the word and, if any characters are left //* check to see if the word in already in our array //* If so, add one to that word's counter //* If not, is there room to add it to the array? //** If so, add the word and a counter to the arrays, setting the //** counter to 1. //** If not, print the error message and abort the program [exit(1);] //* Print all the words found, with their counts, in.csv format. //* Clean up the arrays we created

4 Define arrays word[]count[]

5 Add new element into arrays word1 word2 word3 word4 word5 word6 word7 word8 10 11 12 15 17 1 9 10 word[]count[] word9

6 Add new element into arrays word1 word2 word3 word4 word5 word6 word7 word8 10 11 12 15 17 1 9 10 word[]count[] word9

7 Add new element into arrays word1 word2 word3 word4 word9 word5 word6 word7 word8 10 11 12 15 1 17 1 9 10 word[]count[] word9

8 Delete arrays delete [] word; delete [] count;

9 Test your program Test your program by test0.in Test your program by lglass.txt searching function: try seqOrderedSearch() and binarySearch() individually use time() function to check the running time (optional)

10 Submission wordcount.cpp only modify this file in your assignment *.xls use Excel to read in your output.cvs file do the histogram plot

11


Download ppt "Lin Chen 09/13/2011. Count words number in the file arrayUtils.h include the adding functions template int addInOrder (T* array, int& size, T value);"

Similar presentations


Ads by Google