程序代码:
#include <stdio.h> void main() { int n = 0, sum = 0; while (scanf("%d", &n) != EOF) { sum = 0; while (n % 10) { sum += n % 10; n = n / 10; } printf("%d\n", sum); } }
#include <stdio.h> void main() { int n = 0, sum = 0; while (scanf("%d", &n) != EOF) { sum = 0; while (n % 10) { sum += n % 10; n = n / 10; } printf("%d\n", sum); } }