SHARE
TWEET

inserare maxim minim

AnaBerende Feb 27th, 2020 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int v[1001];
  5. int main()
  6. {
  7.     int i, n, p, x, minim=INT_MAX, maxim=INT_MIN, pmax, pmin;
  8.     cin>>n;
  9.     for(i=1; i<=n; i++)
  10.     {
  11.         cin>>v[i];
  12.     }
  13.     for(i=1; i<=n; i++)
  14.     {
  15.         if(v[i]>maxim)
  16.         {
  17.             maxim=v[i];
  18.             pmax=i;
  19.         }
  20.     }
  21.     for(i=1; i<=n; i++)
  22.     {
  23.         if(v[i]<minim)
  24.         {
  25.             minim=v[i];
  26.             pmin=i;
  27.         }
  28.     }
  29.     for(i=n; i>=pmax; i--)
  30.     {
  31.         v[i+1]=v[i];
  32.     }
  33.     x=maxim/2;
  34.     v[pmax+1]=x;
  35.     n=n+1;
  36.     if(pmax<pmin)
  37.     {
  38.         pmin++;
  39.     }
  40.     for(i=n; i>=pmin; i--)
  41.     {
  42.         v[i+1]=v[i];
  43.     }
  44.     x=minim*2;
  45.     v[pmin+1]=x;
  46.     n=n+1;
  47.     for(i=1; i<=n; i++)
  48.     {
  49.         cout<<v[i]<<" ";
  50.     }
  51.     return 0;
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top