英语阅读真是令人头痛的东西。可怜的子航想利用寒假时间突破英语难题。当他拿到一篇英语阅读时,他很好奇作者最喜欢用那些字母。
输入
一句30词以内的英语句子
输出
统计每个字母出现的次数
样例输入 复制
However,the British don't have a history of exporting their foodstuffs,which makes it difficult for restaurants in Hong Kong to source authentic ingredients.
样例输出 复制
a:6 b:1 c:4 d:4 e:12 f:7 g:4 h:10 i:13 k:2 l:1 m:1 n:9 o:12 p:1 r:10 s:9 t:15 u:5 v:2 w:2 x:1 y:1
#include <iostream>
#include <map>
#include <cctype>
using namespace std;
int main(){
map<char,int>s;
char c;
do{
cin >> c;
if(isalpha(c)){
c = tolower(c);
s[c] ++;
}
}while(c != '.');
for(map<char,int>::iterator iter = s.begin();iter !=s.end(); iter++)
cout << iter->first << ":" << iter->second << endl;
return 0;
}