题解 | #数位之和#
数位之和
http://www.nowcoder.com/practice/5e85cc26475449648e668aa98e92d05b
#include <stdio.h>
#include <math.h>
int main()
{
int n;
scanf("%d", &n);
int he = 0;
for (int i = 0; i <= 9; i++)
{
he += (int)(n / pow(10,9 - i)) % 10;
}
printf("%d", he);
return 0;
}