#include#include #include #include #define UINT unsigned int using namespace std; typedef struct _Word_info { string word; int freq; } Word_info; bool compareTo(const Word_info& x, const Word_info& y); string lowcaseString(const string &s); int main(void) { vector word_vector; string word; Word_info word_info; while( cin >> word ) { bool flag= false; word = lowcaseString(word); if( word_vector.size() == 0) { word_info.word = word; word_info.freq = 1; word_vector.push_back(word_info); continue; } for(UINT i = 0; i < word_vector.size(); i++) { if(word_vector[i].word == word) { word_vector[i].freq++; flag = true; } } if( flag==false) { word_info.word = word; word_info.freq = 1; word_vector.push_back(word_info); } } sort(word_vector.begin(), word_vector.end(), compareTo); for(UINT i = 0; i < word_vector.size(); i++) { cout << word_vector[i].word << ' ' << word_vector[i].freq << endl; } return 0; } string lowcaseString(const string &s) { char* buf = new char[s.size()+1]; s.copy(buf, s.size()); for(UINT i = 0; i < s.size(); i++) buf[i] = tolower(buf[i]); string word(buf, s.size()); delete buf; return word; } bool compareTo(const Word_info& x, const Word_info& y) { return x.word < y.word; }