Advertisement
Guest User

Problema 1

a guest
Jan 29th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int x, even_sum = 0;
  7.     int reversed_num = 0;
  8.     cin >> x;
  9.  
  10.     while (x != 0) {
  11.         int last_digit = x % 10;
  12.         if (!(last_digit & 1)) {
  13.             even_sum += last_digit;
  14.         }
  15.         reversed_num = reversed_num * 10 + last_digit;
  16.         x /= 10;
  17.     }
  18.  
  19.     cout << reversed_num << " " << even_sum;
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement