I have this basic code setup up and two functions set up shown below (word.h and word.cpp). I need write a simple class to represent the string of sorted letters, including a method to sort the letters of a string into alphabetical order.I then need to write some output code to output all the entries of the anagram array to standard output, putting the anagram and all of the words which are anagrams on the same line, like this:
elmno lemon melon
The output produced by your code at the end of exercise 1 will be an unsorted anagram dictionary. Clearly, you could sort this output using the sort program
for (int i = L - 1; i >= 0; i--) cout << Dictionary[i].Getword() << endl;
exit(EXIT_SUCCESS);
}
word.h=
#ifndef WORD_H
#define WORD_H
#include <string>
using std::string;
class Word{
public:
void Setword (string);
string Getword();
private:
string Actual;
};
#endif
word.cpp=
#include <stdlib.h>
#include "word.h"
#include <iostream>
using namespace std;
void Word::Setword (string t) {
Actual = t;
}
string Word::Getword(){
return Actual;
}
I can use either a heap or bubble sort but think the heap will be more efficient, so any help coming up with a sort wud be great! Another function will also probably have to be created but i've just about ran out of ideas and really struggling to find a solution.