Advertisement
amermo

Samostalni 4 - Z32

Mar 25th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. template <typename UporediviTip>
  4. void Analiza(const UporediviTip A[], int N, int &Bmin, int &Bmax)
  5. {
  6.     Bmin = 0;
  7.     Bmax = 0;
  8.     UporediviTip mini(A[0]), maxi(A[0]);
  9.     for(int i(1); i < N; i++)
  10.     {
  11.         if(A[i] < mini)
  12.             mini = A[i];
  13.         if(A[i] > maxi)
  14.             maxi = A[i];
  15.     }
  16.     for(int i(0); i < N; i++)
  17.     {
  18.         if(A[i] == mini)
  19.             Bmin++;
  20.         if(A[i] == maxi)
  21.             Bmax++;
  22.     }
  23. }
  24.  
  25. int main()
  26. {
  27.     int N1, N2;
  28.     double Niz[10] = {2.5, 6, 1.25, 6, 6, -2.19, -1, 0, 3, 1};
  29.     Analiza(Niz, 10, N1, N2);
  30.     std::cout << "Bmin: " << N1 << std::endl << "Bmax: " << N2;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement