Blame view

P33839_en/S002-AC.cc 322 Bytes
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str;
	int sum;
	while(1)
	{
		cin >> str;
		if(cin.eof())
		{
			return 0;
		}
		sum = 0;
		for(int i = 0; i < str.size(); i++)
		{
			sum += str[i]-48;
		}
		cout << "The sum of the digits of " << str << " is " << sum << "." << endl;
	}
}