HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Forums > Discussion of problems > topic:


Problem "The sum of digits"

There is a contest!

В настоящий момент идёт турнир. Некоторая информация и функции сервера недоступны до его окончания.

imesecanFeb.13.2011 at 10:55:31 AM
0The question doesn't mention the number of digits. So, the number can have 4 or five digits or 10 digits.

As far as the number has digits we take the digits one by one; and then calculate the sum.

imesecanFeb.17.2011 at 09:06:42 AM
1You can use a while loop
copiednum=num;
while (copiednum>0)

and always get the last digit using %10 then divide the number by 10. When number has 1 digit and you divide it by 10, the number will be then 0 and it will quit from the loop.

imesecanFeb.20.2011 at 01:24:51 PM
2Post is deleted

imesecanFeb.20.2011 at 01:53:15 PM
3Your program using a loop somewhere and it's going probably infinite :)

Or it's expected to solve in one second but your solution is taking more...


www.contester.ru