c++ string code-HELP
hi,
Using the simple code where a=1, b=2, c=3 etc a word can be assigned a (non-unique) score. For example computer=105. I want to write a program that can count the number of words in a text file that have a score specified by the user of the program. I want to use the program to find the number of words in a file that have a score of exactly 100.
Any help would be much appreciated
Mike
Using the simple code where a=1, b=2, c=3 etc a word can be assigned a (non-unique) score. For example computer=105. I want to write a program that can count the number of words in a text file that have a score specified by the user of the program. I want to use the program to find the number of words in a file that have a score of exactly 100.
Any help would be much appreciated
Mike
0
Comments
Main problem is how I go about assigning the letters numbers, for example, a=1, b=1, c=1, etc. And then how to get the system to add these up to work out whether they equal 100 or not.
maybe a 2 deminsional array?
[1]
[2]
[c'][3]
something like that would work
you'll want a pretty good searching algorithm because you're going to have to traverse that array for every letter of every word. summing COULD get a little slow on a large text file.
edit--
if you have the time i'd highly suggest using a hashtable for this
there
i attached code for JHashtable.h and JHashtable.cpp. maybe you can find it handy
m
ooo and when you find a word with that value you could push the word down onto a stack along with the colXrow coordinates of the word in the text file, based on total line count and character width. that way the end user could precisely find each word in the original text file.
All we've learnt is structures, strings, classes, arrays, getline function, functions, inheritance, loops, pointers, three-vectors. ie, no hash tables or ascii value, what is an ascii value???
what would be the best way to do this with my knowledge.
Here are my thoughts;
-an array to assign the numbers to letters
-some form of loop to run through every word in the text file (not sure how this would work, any help would be much appreciated)
-and then a count to count the number of letters with 100 points say
thanks
~Cyrix