Morteza Kashi  

 

An interesting program dealing with word anagrams and looking up that anagram in a dictionary

This program is a good example of using vectors in C++. I have used vectors to store words. I have used binary search to find words in the "input.txt" file whose words are stored in a Vector. I have also used a very interesting recursive function to find the anagrams of words.

An anagram of a word is a word that can be formed by changing the position of letters in a word. For example, any of the  following words are an anagram for "Work"

Rowk, Korw,Orkw, Orwk and so on.

Here we have an input file called "intest.txt". This file contains the following text:

osket 2 1 3
fruom 2 3 4
fabfel 2 3 5
rivfey 2 2 6

Now, I will explain what I  want to do with this text. Before going any further, I must mention that we  also have an input file called "input.txt". Each line of this file contains a word.

As we can see we have one word  followed by three integers in each line of "intest.txt" file . For example we have osket in the first line. First of all, there is only one anagram of this word that could be found in "input.txt". My program finds this word in first step. Now the first integer after "osket" tells to my program that it has to pick up 2 letters from the found anagram. The second and the third integers tells to my program that my program should pick up the letter in the first and the third position in that anagram. For example if the found anagram is "stoke" , my program should pick the first and the third letter in this word and put them together to make   "so". My program does the same thing for other lines in file "intest.txt" file .

My program put all of the obtained pieces together to form a new word. Then, again, there is only one anagram of this word that could be found in "input.txt" file. My program is supposed to find this anagram and report it.

The program prints out the found anagrams for each word in each line of file "intest.txt" and the final explained anagram.

The program will output the result to an output file named "output.txt" on the C drive.

You can find the "intest.txt"  and "input.txt" files by clicking on the following links:

intest.txt

      input.txt      

Please find my C++ code for this program by clicking on the following link:

Anagram.cpp

Please click on the following link, should you want to see the execution of the program. To do that,  Save the file "Credit.exe" on your desktop or somewhere else on your computer. Then, double click on it to see the execution of the program.

Anagram.exe

Please contact me by clicking HERE and filling out the coming simple  form, should you have any question about this program.

3D animated signs