Code: //分解正整数num的各位数字,返回各位数字之和 int func(int num) { int sum = 0; do { sum + =num % 10; // 累加当前位数字 num / = 10; // 求下一个数值位 }while (num); return sum; }