题解 | 数位之和
#include <stdio.h>
int main() {
long n,sum=0;
scanf("%ld",&n);
while(n){
sum += n%10;
n = n/10;
}
printf("%ld",sum);
return 0;
}
#include <stdio.h>
int main() {
long n,sum=0;
scanf("%ld",&n);
while(n){
sum += n%10;
n = n/10;
}
printf("%ld",sum);
return 0;
}
相关推荐