Niflheimr wants to build a chatbot on his facebook. So that, everytime when he becomes offline, the chatbot will automatically chat with other people.
This chatbot's data bases on chatlog, in the beginning, the log is empty.
Here's the rule of the chatbot: upon reception of a "sentence" from a person,
1. If the chatbot has logged a "comment" for the sentence before, it will reply the "comment" he logged before.
2. If the chatbot hasn't seen the "sentence" before, it will simply reply "what's that means?" and then log the following reply of the person as the corresponding "comment" for the "sentence".
Here's an example:
Person: Hi
Chatbot: what's that means?
Person: Hi
(chatbot now logs 'Hi' -> 'Hi')
Person: Hi
Chatbot: Hi
Oh, here's an another example.
Person: Hello
Chatbot: what's that means?
Person: gtg
(chatbot now logs 'Hello' -> 'gtg')
Person: Hello
Chatbot: gtg
There are 4 testcases
for testcase 1: all input sentences will be only one word , and the chatbot have never seen it before.
for testcase 2: all input sentences the chatbot have never seen before.
for testcase 3: all input setences will be only one word.
Hint:
1. You can use std::map to store the chatog.
2. You can use std::getline (std::cin,string) to get from stream into string.
How to use getline:
// how to use getline
#include <iostream>
#include <string>
int main ()
{
std::string name;
std::cout << "Please, enter your full name: ";
std::getline (std::cin,name);
std::cout << "Hello, " << name << "!\n";
return 0;
}
There are a lot of sentences. and each line contains one sentence.
"_END" means the END.
Don't output anything with _END
1. If the chatbot has logged a "comment" for the sentence before, it will reply the "comment" he logged before.
2. If the chatbot hasn't seen the "sentence" before, it will simply reply "what's that means?" and then log the following reply of the person as the corresponding "comment" for the "sentence".
The output will be the chatbot's reply for each input sentence.