题解 | 数位之和
数位之和
https://www.nowcoder.com/practice/5e85cc26475449648e668aa98e92d05b
#include <stdio.h>
int main() {
int sum = 0;
char first_ch;
int digit;
scanf("%c", &first_ch);
if (first_ch == '-') {
} else {
sum += first_ch - '0';
}
while (scanf("%1d", &digit) == 1) {
sum += digit;
}
printf("%d\n", sum);
return 0;
}