题解 | #数字之和#
数字之和
https://www.nowcoder.com/practice/ae759916631f4711a90c4d4d9657f4b0
#include <iostream>
int func(int x) {
int res = 0;
while (x != 0) {
res += x % 10;
x /= 10;
}
return res;
}
int main() {
int n;
while (scanf("%d", &n) == 1)
printf("%d %d\n", func(n), func(n * n));
return 0;
}
