题目描述
Write a program which reads an integer and prints sum of its digits.
输入描述
The input consists of multiple datasets.
For each dataset, an integer x is given in a line. The number of digits in x does not exceed 20000.
The input ends with a line including single zero. Your program should not process for this terminal symbol.
输出描述
For each dataset; print the sum of digits in x.
样例输入
123
55
1000
0
样例输出
6
10
1
以下是我的代码,我想知道是哪里出现了问题没有输出结果
#include <iostream>
using namespace std;
int main()
{
int n ,m, y = 0;
while (cin >> n);
{
if (n == 0)
{
return 0;
}
else
{
m = n;
while (m != 0)
{
m = m / 10;
y = y + m % 10;
}
cout << y << endl;
}
}
return 0;
}