The goal of this assignment is to write a program that arranges a list of words into separate lists of anagrams. Your program should read a text file which will be the input to your program and contains a list of words to be sorted into anagrams. The program should print to a file the lists of anagrams in the following way:
1. All the words that are anagrams of each other are displayed all on one line; words with no anagrams will be displayed alone.
2. The words on each line should be in alphabetical order.
3. Lines of words are sorted alphabetically according to the first word of a line.
4. Each word on a line should be separated by a space but otherwise there should be no spaces.
I wrote the following code but it's not working properly , and I still can't figure out how to write a print function.
All you have to do is write an algorithm that tells whether two words are anagrams; everything else is rudimentary.
1. Create a vector of vectors of type string (This is akin to a two-dimensional string array, where rows represent strings and columns their anagrams.).
2. Read a string.
3. If this is an anagram of an existing string, add it to this row. Otherwise, add it to a new row.
4. Sort the columns.
5. Sort the rows.