Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Runtime.CompilerServices;
- using System.Linq;
- namespace testing
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = new List<int>();
- string userInput = null;
- while (userInput != "exit")
- {
- Console.WriteLine("Введи число:");
- int newNumber = Convert.ToInt32(Console.ReadLine());
- numbers.Add(newNumber);
- Console.WriteLine("exit - для выхода. \nsum - вывести сумму. \nНажмите enter, чтобы продолжить ввод.");
- userInput = Convert.ToString(Console.ReadLine());
- Console.Clear();
- if (userInput == "sum")
- {
- int total = numbers.Sum(x => Convert.ToInt32(x));
- Console.WriteLine(total + " - Сумма");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement