#include<stdio.h>
#include<string.h>
int main ()
{
char a[100] = { 0 };
int i=0,j=0,b[100] = { 0 };
int n,max=0,c;
scanf_s("%d\n", &n);
gets(a);
c = strlen(a);
for (; i < c; i++)
{
for (j = i + 1; j <= c; j++)
{
if (a[i] == a[j])
b[i]++;
else
continue;
}
}
max = b[0];
for (i = 1; i < c; i++)
{
if (b[i] > max)
max = b[i];
}
printf("出现次数最多%d次的数字是",max+1);;
for (i = 0; i < c; i++)
{
if (b[i] == max)
printf("%c ", a[i]);
}
}
定一系列正整数,对每个正整数的每一位数字统计0~9各个数字的出现次数,求出现次数最多的数字。输入:是整数n(1<=n<=100),表示有n个整数;第二行是n个整数值
最新推荐文章于 2023-11-08 11:35:15 发布