#include #include #include #include #include "Map.h" bool compString(const std::string& s1, const std::string& s2) { return s1 > s2; } //#include int main() { // std::map jiji; typedef ecci::Map WordCount; WordCount wordCount; std::string word; while ( std::cin >> word ) ++wordCount[word]; // for ( WordCount::ConstIterator itr = wordCount.constBegin(); itr != wordCount.constEnd(); ++itr ) // std::cout << itr.getKey() << ": " << itr.getValue() << std::endl; typedef std::map< long, std::list< std::string >, std::greater > TopWords; TopWords topWords; for ( WordCount::ConstIterator itr = wordCount.constBegin(); itr != wordCount.constEnd(); ++itr ) topWords[ itr.getValue() ].push_back( itr.getKey() ); for ( TopWords::const_iterator pairItr = topWords.cbegin(); pairItr != topWords.cend(); ++pairItr ) { std::cout << (*pairItr).first << "\t"; const std::list& words = (*pairItr).second; for ( std::list::const_iterator wordItr = words.cbegin(); wordItr != words.cend(); ++wordItr ) std::cout << *wordItr << ' '; std::cout << std::endl; } }