标签:pac math cstring 字符 ble amp tps ring else
1042 字符统计 (20分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805280817135616
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <string> using namespace std; int main() { char chr[1002]; int arr[26]={0}; cin.getline(chr,1002); for(int i=0;i<strlen(chr);i++) { if(chr[i]>=‘a‘&&chr[i]<=‘z‘) { arr[chr[i]-‘a‘]++; } else if(chr[i]>=‘A‘&&chr[i]<=‘Z‘) { arr[chr[i]-‘A‘]++; } } int max=0; char chr1; for(int i=0;i<26;i++) if(arr[i]>max) { max=arr[i]; chr1=i+‘a‘; } printf("%c %d\n",chr1,max); return 0; }
标签:pac math cstring 字符 ble amp tps ring else
原文地址:https://www.cnblogs.com/jianqiao123/p/12234029.html