标签:字母统计
3 abcd bbaa jsdhfjkshdfjksahdfjkhsajkf
a a j
#include<stdio.h> #include<string.h> struct zifu1 { char zifu; int cou; }a[24]; int main() { //freopen("A.txt","r",stdin); //freopen("AA.txt","w",stdout); char b[1015];int c; scanf("%d",&c);getchar(); for(int k=c;k>0;k--) { for(int j=0;j<26;j++) { a[j].zifu=‘a‘+j;a[j].cou=0; } scanf("%s",b);int lon; lon=strlen(b); for(int i=0;i<lon;i++) for(int j=0;j<26;j++) if(b[i]==‘a‘+j) { a[j].cou++; break; } char max1=‘a‘;int max2=0; for(int i=0;i<26;i++) { //cout<<a[i].zifu<<" "<<a[i].cou<<endl;
if(max2<a[i].cou) { max2=a[i].cou; max1=a[i].zifu; } } printf("%c\n",max1); //fclose(stdin); //fclose(stdout); } return 0; }
标签:字母统计
原文地址:http://blog.csdn.net/qiuyushuofeng/article/details/46565883