The problem is concerned with text occurrence and Im having problems with storing inputs.
INPUT:
abc defghi jkl
bag pencil bag notebook
OUTPUT:
abc 0
defghi jkl
bag 1
pencil bag notebook
INPUT EXPLAINED:
It is to understood that the first word in the input is the “KEYWORD” to be search in a set of strings and the following set of strings are the words where you will search the occurrence of the “KEYWORD”.
OUTPUT EXPLAINED:
The output consists of the “KEYWORD” followed by the number of its occurrence in the set of strings then next line consists of the set of strings.
so I was experimenting with this code
string text;
string key;
while(cin >> key && getline(cin, text, 'n'))
{
cout << key << endl;
cout << text << endl;
}
Its just an experimental draft on how to get the words to be placed on the string but it doesn’t work. Please suggest a way on how to get strings for that kind of problem.