1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include<fstream> #include<string> #include<map> using namespace std;
int (int argc, char *argv[]) { ifstream in("in.txt"); ofstream out("out.txt"); string c; map<string, int> stringNum; while (in >> c) { stringNum[c]++; } for (map<string, int>::iterator it = stringNum.begin(); it != stringNum.end(); it++) { out << it->first << " : " << it->second << endl; } in.close(); return 0; }
|
近期评论