代码如下:
#include<stdio.h>
#include<string.h>
main()
{
int num=0;
int count=0;
int temp=0;
int sz=0,i,j;
int a[]={3,1,4,7,2,1,1,2,2};
sz=sizeof(a)/sizeof(a[0]);
for(i=0;i<sz;i++)
{
temp=0;
for(j=i;j<sz;j++)
{
if(a[i]==a[j])
temp++;
if(count<temp)
{
count=temp;
num=a[i];
}
}
}
printf("%d %d\n",num,count);
}
结果如下:
1 3
请按任意键继续. . .