代码如下:
#include int sum(int n){ if(n == 0) return 0; else return n % 10 + sum(n / 10);}int main(void){ int n; scanf("%d", &n); printf("%d\n", sum(n)); return 0;}