[ create a new paste ] login | about

Link: http://codepad.org/vJS8zDBq    [ raw code | output | fork ]

C++, pasted on Dec 18:
#include <iostream>
#include <sstream>
#include <string>
#include <map>
 
using namespace std;
 
int main()
{
    string s, d; 
    s = "v1 v1 v2 v2 v2 v3";
    stringstream tmp;
    tmp << s;
    map <string,int> M;
    while (tmp >> d)
        ++M[d];
        int max = -1;
        for (map <string,int> :: iterator it = M.begin(); it != M.end(); ++it)
                max = (max > it->second) ? (max) : (it->second);
        cout << max << endl;
    return 0;    
}


Output:
1
3


Create a new paste based on this one


Comments: