Advertisement
saira12tabassum19

Untitled

Jul 31st, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include<stdio.h>
  2. int sort(int ar[],int n)
  3. {
  4. int i,j,temp;
  5. for(i=0;i<n;i++)
  6. {
  7. for(j=0;j<n-1-i;j++)
  8. {
  9. if(ar[j]>ar[j+1])
  10. {
  11. temp=ar[j];
  12. ar[j]=ar[j+1];
  13. ar[j+1]=temp;
  14. }
  15. }
  16. }
  17. }
  18. int main()
  19. {
  20.  
  21. int n,ar[10000],i,j,countc[10000],count=1,k,t=1;
  22. while(scanf("%d",&n)!=EOF)
  23. {
  24. for(i=0;i<n;i++)
  25. {
  26. scanf("%d",&ar[i]);
  27. }
  28.  
  29. sort(ar,n);
  30. for(i=0;i<n;i++)
  31. {
  32. for(j=0;j<n;j++)
  33. {
  34. if(ar[j]==ar[i]){
  35. countc[i]=count++;
  36. }
  37. } count=1;
  38. }
  39. printf("Case %d:\n",t);
  40. for(k=0;k<n;k++)
  41. { if(ar[k]==ar[k+1]);
  42. else printf("%d %d\n",ar[k],countc[k]);
  43. }
  44.  
  45. t++;count=1;
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement