It's a simple program I think. It just needs to sort the input that is in a txt file.
The input will be this, for instance: This is is an an icorrect sntence.
Input Output (on the screen)
delete("is",2)
print 1:This 2:is 3:an 4:an 5:icorrect 6:sntence
delete("an",3)
print 1:This 2:is 3:an 4:icorrect 5:sntence
delete("icorrect",4)
print 1:This 2:is 3:an 4:sntence
insert("incorrect",4)
print 1:This 2:is 3:an 4:incorrect 5:sntence
delete("sntence",5)
insert("sentence",5)
print 1:This 2:is 3:an 4:incorrect 5:sentence
neighbors("is") 2:is previous:This next:an
And the output will be: This is a correct sentence.
I'm wanting to use array-based lists/linked lists. How do I load the input into the list?
Code:
vector<string> words;
string word;
ifstream fin("text.txt") // use ifstream object to get info from file
while (fin >> word) // will read until there is no more info in the file
words.push_back(word); // add the word to the vector
Thanks !