题目链接:1042 字符统计
代码
#include <iostream>
using namespace std
;
int main(){
string s
;
int a
[200] = {0};
getline(cin
,s
);
for(int i
=0;i
<s
.length();i
++){
if(s
[i
]>='A' && s
[i
]<='Z') s
[i
] = s
[i
]-'A'+'a';/转小写
if(s
[i
]>='a' && s
[i
]<='z') a
[s
[i
]]++;
}
int max
= 0;
char m
= 'a';
for(int i
='a';i
<= 'z';i
++){
if(a
[i
]>max
){
max
= a
[i
];
m
= i
;
}
}
cout
<< m
<< ' ' << max
<< endl
;
return 0;
}
转载请注明原文地址:https://blackberry.8miu.com/read-6734.html