Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int CountTimes(string userInput)
- { int number = int.Parse( userInput);
- int sum = 0;
- int newValue = number;
- int count = 0;
- while (newValue > 0)
- {
- number = newValue;
- sum = 0;
- while (number > 0)
- {
- sum += number % 10;
- number /= 10;
- }
- newValue = newValue - sum;
- count++;
- }
- return count;
- }
- static void Main(string[] args)
- {
- Console.WriteLine("введите число");
- string userInput = Console.ReadLine();
- Console.WriteLine("вычитaние можно выполнить: "+ CountTimes(userInput)+" раз");
- Console.ReadKey();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement