Advertisement
rotti321

Tematica siruri [X]

May 5th, 2022
727
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     ///Gasiti min prin prima jumatate si max din a II-a jumatate
  8.     ///n par
  9.     int a[1000], n, minn, maxx;
  10.     cin >> n;
  11.     for( int i=1; i<=n; i++){
  12.         cin >> a[i];
  13.  
  14.     }
  15.     minn =a[1];
  16.     for(int i=1;i<=n/2;i++)
  17.     {
  18.  
  19.         if(a[i]<minn)
  20.             minn=a[i];
  21.     }
  22.     maxx=a[n/2+1];
  23.     for (int i=n/2+1; i<=n; i++) {
  24.         if (a[i]> maxx) {
  25.             maxx=a[i];
  26.         }
  27.     }
  28.     cout << minn << " " << maxx;
  29.     return 0;
  30. }
  31. /** Tematica siruri
  32. - min,max
  33. - parcurgeri pe secvente
  34. - sume, produse, medii
  35. - cautari ale unor valori
  36. - verificari paritate, comparari
  37. */
  38.  
Advertisement
RAW Paste Data Copied
Advertisement