English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Read a file called 'words' which contains one word per line. Read a file called 'search' that contains lines of text. Output the number of times each word in the words file is found in the search file, where the output file name is 'output'. The search is for exact matches, e.g. one ne One, for ne fortune. For example,

words:
one
two
three

search:
The one thing that is important is that one can find two things.
One other thing is that one plus one is two.

output:
one 4
two 2
three 0

2007-03-07 01:39:30 · 2 answers · asked by confused 1 in Computers & Internet Programming & Design

2 answers

Read the list of words first and store them in a array.

Now create a loop to read the file
Now create another loop within the file read loop to check each element of the array against the file record just read.
If the element is found then add 1 to the count array at word element.
End loop
End loop

Create a new loop to print the word array and the count array.
End loop

That should do it.

2007-03-07 02:04:04 · answer #1 · answered by AnalProgrammer 7 · 0 0

there is not any absolute, time-honored 'least complicated' language. some are undemanding for some human beings to income yet not extremely undemanding for others, and vice versa. Python is between the least complicated to income and relatively cautioned for beginners. user-friendly is likewise somewhat undemanding to income, yet some human beings have self assurance user-friendly teaches programmers undesirable behavior and could subsequently be prevented; i'm not sure on that myself. Pascal is with regard to comparable to user-friendly, a minimum of in line with what I undergo in concepts from my short fling with it. C is slightly greater problematic (yet advantageous and effective), and C++ is slightly greater problematic than that (OOP could be gruesome to income for a beginner). some style of assembly could be seen 'maximum complicated,' in spite of if it somewhat is extremely purely time-eating to code in. you moreover mght could desire to be very careful approximately employing your records in its suitable context, or you will get wildly unpredictable consequences (some are purely incorrect on an identical time as others can corrupt different records or maybe crash your device). i in my opinion want assembly simply by fact it gets rid of each and all the abstraction different languages introduce. i will cope with questioning procedurally greater effective than an OOP approach. you would be able to additionally do programming with a hex editor, in case you're so susceptible. that could in all probability be the main complicated approach wanting employing binary. to try this you will in all probability could desire to jot down your guy or woman compiler/assembler, and you will could desire to have the two an outstanding memory or an extremely thorough yet properly prepared reference instruction manual.

2016-10-17 11:42:55 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers