题解 | #Digital Roots# #C
Digital Roots
https://www.nowcoder.com/practice/cef727d0af33479c9fb4a9c120702414?tpId=40&rp=1&ru=%2Fta%2Fkaoyan&qru=%2Fta%2Fkaoyan&difficulty=&judgeStatus=&tags=&title=72&sourceUrl=&gioEnter=menu
#include <stdio.h> int main() { int a; while (scanf("%d", &a) != EOF) { int sum=0; while (1) { sum=0; while (a) { sum+=a%10; a/=10; } if (sum<10){ break; }else { a=sum; } } printf("%d\n", sum); } return 0; }#c#