ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Форумы > Обсуждение задач > тема:


Задача "The sum of digits"

Идёт турнир!

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

imesecan13.фев.2011 в 10:55:31
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.

imesecan17.фев.2011 в 09:06:42
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.

imesecan20.фев.2011 в 13:24:51
2Реплика удалена

imesecan20.фев.2011 в 13:53:15
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