#include<cstdio> int sum(int x) { int sum = x % 10; while (x % 10 != x) { x /= 10; sum += x % 10; } return sum; } int main() { int x; while (scanf("%d", &x) != EOF) { printf("%d ", sum(x)); printf("%d\n", sum(x * x)); } return 0; }
#include<cstdio> int sum(int x) { int sum = x % 10; while (x % 10 != x) { x /= 10; sum += x % 10; } return sum; } int main() { int x; while (scanf("%d", &x) != EOF) { printf("%d ", sum(x)); printf("%d\n", sum(x * x)); } return 0; }