fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int a[]={3,2,3,2,4,3};
  5. int n=sizeof(a)/sizeof(a[0]);
  6. int maxi=-100;
  7. int mini=1e9;
  8. int maxel=0;
  9. int minel=0;
  10. int count=0;
  11. for(int i=0;i<n;i++){
  12. count=1;
  13. for(int j=i+1;j<n;j++){
  14. if(a[i]==a[j]){
  15. count++;
  16. }
  17. if(count>maxi){
  18. maxi=count;
  19. maxel=a[i];
  20. }
  21. if(count<mini){
  22. mini=count;
  23. minel=a[i];
  24. }
  25.  
  26. }
  27.  
  28.  
  29.  
  30. }
  31. cout<<maxel<<"-"<<maxi<<endl;
  32. cout<<minel<<"-"<<mini<<endl;
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
3-3
3-1