#include
#include
#include
#include
using namespace std;
int main()
{
string input_s = "i am a boy.n
she is a girl.";
string word;
map freq;
string s;
while(getline(input_s,s))
{
for ( std::string::iterator it=s.begin(); it!=s.end(); ++it)
{
if(*it == ' ')
{
if(freq.find(word) == freq.end()) //First time the word is seen
{
freq[word] = 1;
}
else //The word has been seen before
{
freq[word]++;
}
word = "";
}
else
{
word.push_back(*it);
}
}
}
for (std::map::iterator it=freq.begin(); it!=freq.end(); ++it)
std::cout first