Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <map>
- #include <string>
- #include <iostream>
- using namespace std;
- int main()
- {
- ifstream in ("/Users/masha/Documents/PrMap1/PrMap1/input");
- map<string, int> m;
- string s;
- while (in >> s)
- {
- if (isdigit(s[0]) || (s.length()!= 1 && isdigit(s[1])))
- {
- map<string,int>::iterator it = m.find(s);
- if (it != m.end()) m[s]++;
- else m[s] = 1;
- }
- }
- for (map<string, int>::const_iterator it = m.begin(); it != m.end(); ++it)
- cout << it->first << ": " << it->second << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment