一、题目要求
Given a none-negative number, print out the sum of its digits.
Input Format:
A none-negative integer number.
Output Format:
The sum of its all digits.
Sample Input:
123
Sample Output:
6
二、代码
#include<stdio.h>
int main() {
int m,sum=0;
scanf("%d", &m);
while (m > 0) {
sum += m % 10;
m /= 10;
}
printf("%d", sum);
}