C语言:统计任意整型数组中各个基本数字出现最多的数字,并输出相应的次数

#include <stdio.h>
main()
{
    int ap[]={3300024,200341,420034,723004,223004,234001,2300421,20,2},i,max,jiyi,shu[10]={0};
    int len=sizeof(ap)/sizeof(ap[0]);
    for(i=0;i<len;i++)
    {
        jiyi=ap[i];
        while(jiyi)
        {
            shu[jiyi%10]++;
            jiyi=jiyi/10;
        }
    }
    max=shu[0];
    for(i=1;i<=9;i++)
    if(max<shu[i]) max=shu[i],jiyi=i;
    printf("次数最多为数字为%d,次数为%d",jiyi,max);
    getchar();
 }

 

posted @ 2022-11-15 20:38  myrj  阅读(298)  评论(0编辑  收藏  举报