代码:
#include <stdio.h>
int main(){
int a[50];
int i,j,maxCount=0,index=0,nCount=0;
int n;
printf("请输入n的数值:");
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=0;i<n;i++) {
for(j=0;j<n;j++)
{
if(a[j]==a[i])
nCount++;
} if(nCount>maxCount)
{ maxCount=nCount;
index=i;
}
nCount=0;
}
printf("%d\n%d",a[index],maxCount);
}
运行截图: