Advertisement
SergeyPGUTI

6.3.2

Nov 21st, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int CountMax(int A[],int n)
  6. {
  7.     int Max=A[0];
  8.     int Count=1;
  9.     for (int i=1;i<n;i++)
  10.     {
  11.         if (A[i]==Max) {Count++;}
  12.         if (A[i]>Max) {Max=A[i]; Count=1;}
  13.     }
  14.     return Count;
  15. }
  16.  
  17. int main()
  18. {
  19.     int n;
  20.     int *A;
  21.     cin>>n;
  22.     A=new int [n];
  23.     for (int i=0;i<n;i++)
  24.     {
  25.         cin>>A[i];
  26.     }
  27.     cout<<CountMax(A,n);
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement