Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <map>
- using namespace std;
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- bool isWord(string tmp)
- {
- if (isalpha(tmp[0])) return true;
- else return false;
- }
- int main()
- {
- int count=0;
- cout << "Enter count: ";
- cin >> count;
- map <string, int> dict;
- string tmp;
- while (fin >> tmp)
- {
- if (isWord(tmp))
- {
- if (dict.count(tmp)==0)
- {
- dict.insert(pair<string,int>(tmp,1));
- }
- else
- {
- dict.at(tmp)++;
- }
- }
- }
- for (map<string, int>::iterator iter=dict.begin();iter!=dict.end();iter++)
- fout << iter->first << "-" << iter->second << endl;
- fout << "\\\\\\\\\\\\"<< endl;
- for (map<string, int>::iterator it=dict.begin();it!=dict.end();it++)
- if (it->second == count) fout << it->first << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement