Код: Выделить всё
public class Solution {
public int AddDigits(int num) {
string strNum = num.ToString();
while (strNum.Length > 1)
{
int num1 = int.Parse(strNum[0].ToString());
int num2 = int.Parse(strNum[1].ToString());
num1 += num2;
strNum = num1.ToString();
}
Console.WriteLine(strNum);
Console.ReadLine();
return int.Parse(strNum);
}
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... -different
Мобильная версия