LeetCode 258 Add Digits
LeetCode 258 Add Digits
https://leetcode.com/problems/add-digits/
该题主要用到了树根这个概念 ,百度百科链接:http://baike.baidu.com/view/5820558.htm
#include <stdio.h> int addDigits(int num) { return (num - 1) % 9 + 1; } int main() { int num; scanf("%d",&num); printf("%d",addDigits(num)); }