Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CSLight
- {
- class Program
- {
- private static void Main()
- {
- List<int> numbers = new List<int>(7);
- while (true)
- {
- Console.Write("Введите число для добавления в список (exit - выход, sum - сумма всех введенных чисел): ");
- string userInput = Console.ReadLine();
- if (userInput == "exit")
- break;
- if (userInput == "sum")
- {
- Console.WriteLine($"\nСумма всех числа списка: {numbers.Sum()}\n");
- continue;
- }
- if (int.TryParse(userInput, out int number))
- numbers.Add(number);
- else
- Console.WriteLine("\nНекорректно введено число!\n");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement