Advertisement
Carbastan

Numere14

Nov 16th, 2022
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. ifstream cin("numere14.in");
  6. ofstream cout("numere14.out");
  7.  
  8. int main()
  9. {
  10.     int n, s = 0;
  11.     cin >> n;
  12.    
  13.     for(int i = 1; i <= n; ++i)
  14.     {
  15.         int x, X, cifre = 1, c;
  16.         cin >> x;
  17.         X = x;
  18.        
  19.         while(x > 9)
  20.         {
  21.             ++cifre;
  22.             x /= 10;
  23.         }
  24.        
  25.         cifre /= 2;
  26.        
  27.         for(int i = 1; i <= cifre; ++i)
  28.         {
  29.             X /= 10;
  30.         }
  31.        
  32.         c = X % 10;
  33.        
  34.         if(c % 2 != 0) s += c;      
  35.     }
  36.    
  37.     cout << s;
  38.      
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement