Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace While
- {
- class Program
- {
- static void Main(string[] args)
- {
- //команда -> Going home или стъпки под формата на string("1000")
- //стоп: стъпките >= 10000
- //продължаваме: стъпки < 10000
- int steps = 0;
- while (steps < 10000)
- {
- //команда
- string command = Console.ReadLine();
- //проверка
- if (command == "Going home")
- {
- int stepsToHome = int.Parse(Console.ReadLine());
- steps += stepsToHome;
- break;
- }
- else
- {
- //число под формата на стринг -> "1500"
- int walkedSteps = int.Parse(command);
- steps += walkedSteps;
- }
- }
- if (steps >= 10000)
- {
- Console.WriteLine("Goal reached! Good job!");
- }
- else
- {
- Console.WriteLine($"{10000 - steps} more steps to reach goal.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement