https://github.com/root-project/root
Raw File
Tip revision: 1a061d519b3ae358db26b5d9862e127d6ab15329 authored by Fons Rademakers on 05 June 2012, 13:29:43 UTC
tag pro version v5-34-00.
Tip revision: 1a061d5
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;
}


back to top