https://github.com/root-project/root
Tip revision: 17a9fe1937ac27f456dc7a4bfeea01efc6cfd38f authored by Fons Rademakers on 23 February 2011, 13:21:28 UTC
tag patch release v5-28-00a.
tag patch release v5-28-00a.
Tip revision: 17a9fe1
t1224.cxx
/* -*- C++ -*- */
/*************************************************************************
* Copyright(c) 1995~2005 Masaharu Goto (cint@pcroot.cern.ch)
*
* For the licensing terms see the file COPYING
*
************************************************************************/
#include <iostream>
#include <map>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::map;
using std::string;
int main()
{
string s;
map<string, int> counters; // store each word and an associated counter
map<string, int>::iterator iter;
// read the input, keeping track of each word and how often we see it
//while (cin >> s) {++counters[s];}
++counters["This"];
++counters["is"];
++counters["a"];
++counters["test"];
++counters["."];
++counters["test"];
++counters["of"];
++counters["iterator"];
++counters["operation"];
++counters["."];
// write the words and associated counts
for (iter = counters.begin(); iter != counters.end(); ++iter) {
cout << iter->first << "\t" << iter->second << endl;
}
for (iter = counters.begin(); iter != counters.end(); ++iter) {
cout << (*iter).first << "\t" << (*iter).second << endl;
}
return 0;
}