Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int n,s=0;
  6.     cin >> n;
  7.     int a[n];
  8.     for (int i=0 ; i< n; i++){
  9.         int q;
  10.         cin >> q;
  11.         a[i]=q;
  12.         if(q>0) s+=q;
  13.     }
  14.     int min = a[0], max = a[0],z1,z2;
  15.     for (int i=1; i< n; i++){
  16.         if (min > a[i]) {
  17.             min = a[i];
  18.             z1 = i;
  19.         }
  20.         if (max < a[i]){
  21.             max = a[i];
  22.             z2 = i;
  23.         }
  24.     }
  25.     if (z2< z1){
  26.         int l=z2; z2=z1; z1=l;
  27.     }
  28.     int pr=1;
  29.     for (int i = z1+1; i < z2; i++)
  30.         pr*=a[i];
  31.     //  cout << z1 << ' ' << z2 << ' ' << min << ' ' << max << endl;
  32.     cout << s << ' ' << pr;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement