Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int a,ar[100],i,ar1[100],count=0,j,ar2[100],temp,temp1;
- for(i=0;;i++)
- {
- scanf("%d",&a);
- if(a>0)
- ar[i]=a;
- else
- break;
- }
- int len=i;
- for(i=1;i<10;i++)
- {
- for(j=0;j<len;j++)
- {
- if(ar[j]==i)
- count++;
- }
- ar1[i]=count;
- count=0;
- }
- for(i=0;i<10;i++)
- {
- ar2[i]=i;
- }
- for(i=0;i<len;i++)
- {
- for(j=0;j<len-i-1;j++)
- {
- if(ar1[j]<ar1[j+1])
- {
- temp=ar1[j];
- ar1[j]=ar1[j+1];
- ar1[j+1]=temp;
- temp1=ar2[j];
- ar2[j]=ar2[j+1];
- ar2[j+1]=temp1;
- }
- }
- }
- for(i=0;i<=len;i++)
- {
- if(ar1[i]>0)
- printf("%d occurs: %d times\n",ar2[i],ar1[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment