Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = new List<int>();
- bool cycleWork = true;
- while (cycleWork)
- {
- int sumOfNumbers = 0;
- string userInput = Console.ReadLine();
- if (userInput == "exit")
- {
- cycleWork = false;
- }
- else if (userInput == "sum")
- {
- for (int i = 0; i < numbers.Count; i++)
- {
- sumOfNumbers += numbers[i];
- }
- Console.WriteLine($"Сумма чисел равна: {sumOfNumbers}");
- }
- else
- {
- numbers.Add(int.Parse(userInput));
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment