Advertisement
Guest User

Loop

a guest
Oct 8th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int a[100];
  7.     int i,j,n,max=0,m,index;
  8.     cout<<"Please Enter the elements of your aray: "; cin>>n;
  9.     for (i=0;i<=n;i++){
  10.         cout<< "a["<<i<<"] : ";
  11.         cin>>a[i] ;
  12.     }
  13.     for(i=0;i<=n;i++){
  14.         int k=0;
  15.         for (j=0;j<n-1;j++){
  16.              if(a[i] == a[j+1]){
  17.                      k=k+1;
  18.                      }
  19.              }
  20.         if(max<k){
  21.                   max = k;
  22.                   m=a[i];
  23.                   index = i;
  24.                   }
  25.     }
  26.     cout<<"Chisloto koeto se povtarq nai-mnogo e: "<<max<<endl;
  27.     cout<<"Zapochva ot index: "<<index<<endl;
  28.     system("PAUSE");
  29.     return EXIT_SUCCESS;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement