Advertisement
Qpel

masyvai 2 užd

Mar 19th, 2017
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.     int n;
  9.     cin >> n;
  10.     int M[n-1];
  11.     for(int i = 0; i <= n-1; i++){
  12.         cin >> M[i];
  13.     }
  14.  
  15.     int maks = 1, maz = 9999999, msum = 0, minsum = 0;
  16.     for(int i = 0; i < n; i++){
  17.         if(maks < M[i]) maks = M[i];
  18.         if(maz > M[i]) maz = M[i];
  19.     }
  20.  
  21.     for(int i = 0; i < n; i++){       //sumuoja didziausius ir maziausius
  22.         if(M[i] == maks) msum++;
  23.         if(M[i] == maz) minsum++;
  24.     }
  25.  
  26.     //cout << maks << endl << maz << endl;
  27.  
  28.     for(int i = 0; i < n; i++){
  29.         if(M[i] != maks and M[i] != maz) cout << M[i] << " ";
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement