#C290. Reverse Integer Digits and Sum of Odd Digits
Reverse Integer Digits and Sum of Odd Digits
Reverse Integer Digits and Sum of Odd Digits
Given a non-negative integer n, you are to perform two operations:
- Reverse the digits of n and output the resulting integer after removing any leading zeros. In other words, if
\( n = d_1d_2\dots d_k \), then the reversed integer is \( rev(n) = d_k\dots d_2d_1 \) (ignoring any leading zeros in the result). - Compute the sum of all odd digits present in n. That is, sum the digits \( d \) for which \( d \mod 2 = 1 \).
The input will consist of several test cases. For each test case, print the result of the reversal on the first line and the sum of odd digits on the second line.
inputFormat
The first line of input contains an integer T
, representing the number of test cases. Each of the following T
lines contains a single non-negative integer n
.
outputFormat
For each test case, output two lines:
- The first line should contain the reversed integer (with no leading zeros).
- The second line should contain the sum of the odd digits in the integer.
2
1111
24682468
1111
4
86428642
0
</p>