标签:style blog io color ar os sp for 数据
1 #include <stdio.h> 2 #include <string.h> 3 4 int main(){ 5 char s[1100]; 6 int T; 7 int amount[27]; 8 int i; 9 int max; 10 char c; 11 12 scanf("%d",&T); 13 14 while(T--){ 15 scanf("%s",&s); 16 17 memset(amount,0,sizeof(int)*27); 18 19 for(i=0;s[i]!=‘\0‘;i++){ 20 amount[s[i]-‘a‘+1]++; 21 } 22 23 for(i=1;i<=26;i++){ 24 if(amount[i]!=0){ 25 c=i-1+‘a‘; 26 max=amount[i]; 27 break; 28 } 29 } 30 31 for(i=1;i<=26;i++){ 32 if(amount[i]>max){ 33 c=i-1+‘a‘; 34 max=amount[i]; 35 } 36 } 37 38 printf("%c\n",c); 39 } 40 return 0; 41 }
标签:style blog io color ar os sp for 数据
原文地址:http://www.cnblogs.com/zqxLonely/p/4098017.html