Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class program
- {
- static void Main(string[] args)
- {
- List<int> numbers = new List<int>();
- string summation = "sum";
- string exitProgram = "exit";
- bool isWorking = true;
- while (isWorking)
- {
- string userInput = Console.ReadLine();
- if (userInput == summation)
- {
- Console.WriteLine(numbers.Sum());
- }
- else if (userInput == exitProgram)
- {
- isWorking = false;
- }
- else if (int.TryParse(userInput, out int number))
- {
- numbers.Add(Convert.ToInt32(userInput));
- Console.Clear();
- }
- else
- {
- Console.WriteLine("Не удалось распознать ввод, попробуйте еще раз.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement