文章

211

粉丝

1

获赞

1157

访问

47.4k

头像
字母频率 题解:
P1019 贵州大学机试题
发布于2026年3月18日 15:16
阅读数 89

#include<bits/stdc++.h>
using namespace std;
int main(){
	map<char,int> mp;
    string str;
	getline(cin, str);
	int maxc = 0;
	char maxch;
	for(auto it:str){
		if(isalpha(it)){
			char c = tolower(it);
			mp[c]++;
			if(maxc < mp[c]){
				maxc = mp[c];
				maxch = c;
			}	
		}	
	}
	cout << maxch << " " << maxc;
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发