#include <stdio.h> int UnitSum(int x) { int sum = 0; while (x) { sum += x % 10; x /= 10; } return sum; } int main() { int num = 0; while (scanf("%d",&num) != EOF) { while (num > 9) { num = UnitSum(num); } printf("%d ",num); } return 0; }
#include <stdio.h> int UnitSum(int x) { int sum = 0; while (x) { sum += x % 10; x /= 10; } return sum; } int main() { int num = 0; while (scanf("%d",&num) != EOF) { while (num > 9) { num = UnitSum(num); } printf("%d ",num); } return 0; }