Advertisement
AlexAvram

Untitled

Jun 5th, 2025
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. //pv #2858
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n, a[101];
  9.     cin>>n;
  10.     for (int i=1; i<=n; i++)
  11.         cin>>a[i];
  12.     int sum_pare=0, sum_poz_pare=0, nr_div_10=0, sum_poz_imp_div_3=0;
  13.     for (int i=1; i<=n; i++)
  14.     {
  15.         if (a[i]%2==0)
  16.             sum_pare+=a[i];
  17.         if (i%2==0)
  18.             sum_poz_pare+=a[i];
  19.         if (a[i]%10==0)
  20.             nr_div_10++;
  21.         if (i%2==1 && a[i]%3==0)
  22.             sum_poz_imp_div_3+=a[i];
  23.     }
  24.     for (int i=n; i>=1; --i)
  25.         cout<<a[i]<<' ';
  26.     cout<<endl;
  27.     cout<<sum_pare<<endl;
  28.     cout<<sum_poz_pare<<endl;
  29.     cout<<nr_div_10<<endl;
  30.     cout<<sum_poz_imp_div_3<<endl;
  31.  
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement