Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool exit = false;
- List<int> nums = new List<int>();
- while (!exit)
- {
- string input = Console.ReadLine();
- switch (input)
- {
- case "exit":
- exit = true;
- break;
- case "sum":
- int sum = 0;
- foreach (var num in nums)
- {
- sum += num;
- }
- Console.WriteLine("Сумма всех веденных чисел: " + sum);
- break;
- default:
- nums.Add(Convert.ToInt32(input));
- break;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment