#include<stdio.h> int main() { long int n=0; int b; int sum=0;; scanf("%ld",&n); for(;n!=0;) { b=n%10; n=n/10; //为0时候不进入循环 sum+=b; } printf("%ld",sum); }