Advertisement
wym1111

Untitled

Jul 30th, 2023
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int n,x,sum1=0,sum2=0,sum3=0;
  5.     cin>>n;
  6. //    for(int i=0;i<n;i++)
  7. //    {
  8. //        cin>>x;
  9. //        if(x%10==5 && x%3==0)
  10. //            sum1=sum1+x;
  11. //        if(x%10==2 && x%3==0)
  12. //            sum2=sum2+x;
  13. //        if ( !((x%10==5 && x%3==0)||(x%10==2 && x%3==0)) )
  14. //          sum3 += x;
  15. //    }
  16.    
  17.     for (int i = 0; i < n; i ++) {
  18.         cin >> x;
  19.         bool f = 0;
  20.         if (x % 10 == 5 || x % 3 == 0) {
  21.             f = 1;
  22.             sum1 += x;
  23.         }
  24.         if (x % 10 == 2 || x % 3 == 0) {
  25.             f = 1;
  26.             sum2 += x;
  27.         }
  28.         if (!f) sum3 += x;
  29.     }
  30.     cout<<sum1<<" "<<sum2<<" "<<sum3;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement