网上随便搜了一道简单题,作为第一篇blog,题目如上,代码如下: #include <stdio.h> int main(void) { int n=10,count[10]={0,0,0,0,0,0,0,0}; char s[10] = "abacadbb"; puts(s); for(int i=0;i<9;i++) { for(int j=0;j<=i;j++) { if(s[i]==s[j]) { count[i]++;} //找出第一个出现了3次的字符 // if(count[i]==3) // { // printf("%d %c",i+1,s[i]); // goto over; // } } } int temp=0; for(int k=0;k<n k="" if="" count="" k="">temp){temp=count[k];} } printf("字符重复次数最多的字符为:"); for(int k=0;k<n;k++) { if(count[k]==temp){printf("%c ",s[k]);} } printf(",重复了%d次",temp); // over: return 0; } 输出为: