Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
62020 刘轻松 统计字符数量 C++ Accepted 1 MS 280 KB 399 2023-12-16 17:01:34

Tests(10/10):


Code:

#include<iostream> #include<cstring> using namespace std; int main(){ string s; int j; int a[26]={0}; getline(cin,s); for(int i=0;i<s.size();i++){ j = int(s[i]-'a'); a[j]++; } int max = 0; int max_id = 0; //最大值所在的位置下标 for(int i=0;i<26;i++){ if(a[i]>max){ max = a[i]; max_id = i; } } cout<<char(max_id+'a')<<" "<<max; }