题目描述
求一个整数的所有数位之和
输入描述:
输入一行,包含一个整数。
输出描述:
一个整数. int范围内
示例1
输入
12
输出
3
参考
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
while (n!=0)
{
cout << "n:" << n <<"\t" << "n%10:" << n % 10 << endl;
n /= 10;
cout << "n/=10:" << n<<endl;
cout << endl;
}
return 0;
}
