#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void find(char s[])
{
int test[256];
int i;
int max=-1;
char c;
for(i=0;s[i];i++)
{
test[s[i]]++;
}
for(i=0;i<256;i++)
{
if(test[i]>max)
{
max=test[i];
c=(char)i;
}
}
printf("%c\n",c);
printf("%d",max);
}
int main()
{
char s[1000];
scanf("%s",&s);
find(s);
return 0;
}
你代码唯一的问题是没对 test 做初始化,改成
就好了