Accelerated C++ Chapter7 使用关联式容器
Chapter7 使用关联式容器
7.2 字数统计程序
1 int main() 2 { 3 string s; 4 map<string, int> counters; 5 6 while(cin >> s) 7 ++counters[s]; 8 for(map<string, int>::const_iterator it = counters.begin(); 9 it != counters.end(); ++it) 10 { 11 cout << it->first << "\t" << it->second << endl; 12 } 13 14 return 0; 15 }
posted on 2013-10-13 23:20 startfromjava 阅读(147) 评论(0) 收藏 举报
浙公网安备 33010602011771号