Advertisement
labyyysosaaat

LABA

Sep 15th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int j=1;
  4. int s;
  5. int p;
  6. int k;
  7. int main()
  8. {
  9.     int arr[100];
  10.     int n;
  11.    
  12.     cout << "Enter array:" << endl;
  13.     cin >> n;
  14.     if (n <= 1)
  15.         cout << "invalid size" << endl;
  16.    
  17.  
  18.     for (int i = 1; i < n+1; i++)
  19.     {
  20.         cout << "a[" << i << "] = ";
  21.         cin >> arr[i];
  22.         if (i%2==0)
  23.             j =arr[i]*j;
  24.        
  25.     }
  26.     cout << "Multiplication of even-numbered array elements =" << j << endl;
  27.    
  28.     for (int i = 1; i < n; i++)
  29.     {
  30.         if (arr[i] == 0)
  31.         {
  32.             k = i;
  33.             break;
  34.         }
  35.     }
  36.     for (int i = n ; i >= 0; i--)
  37.         if (arr[i] == 0)
  38.         {
  39.             p = i;
  40.             break;
  41.         }
  42.    
  43.     for (int i = k; i <= p; i++)
  44.     {
  45.          s += arr[i];
  46.     }
  47.     cout << "Sum=" << s << endl;
  48.    
  49.  
  50.     system("pause");
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement