Count the number of times a number appears in an array

前端 未结 6 1311
我在风中等你
我在风中等你 2021-01-20 15:48

I\'m working on a small program that counts the number of times an integer appears in an array. I managed to do this but there is one thing I can\'t overcome.

My cod

6条回答
  •  攒了一身酷
    2021-01-20 16:37

    very simple logic to count how many time a digit apper
    #include
      int main()
    {
    int a,b,c,k[10];
    int p[10]={0};
    int bb[10]={0};
    scanf("%d\n",&a);
    for(b=0;b0;b--)
    {
        for(c=b-1;c>=0;c--)
        {
            if((k[b]==k[c])&&(bb[c]==0))
            {
                p[b]=p[b]+1;
                bb[c]=1;
            }
        }
    }
        for(c=0;c

提交回复
热议问题