Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace C_sharp_Light
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool isOpen = true;
- List<int> forSum = new List<int>();
- while (isOpen)
- {
- int number;
- Console.WriteLine("Введите:\n*Число \n*Sum - сложить все числа \n*exit - Выход из программы \n\n");
- string input = Console.ReadLine();
- if(int.TryParse(input,out number))
- {
- forSum.Add(number);
- Console.WriteLine("Число добавлено.");
- Console.ReadKey();
- Console.Clear();
- }
- else
- {
- switch (input)
- {
- case "Sum":
- int res=0;
- for (int i = 0; i < forSum.Count; i++)
- {
- res += forSum[i];
- if (i != forSum.Count - 1)
- Console.Write($"{forSum[i]}+");
- else
- Console.Write($"{forSum[i]}={res}");
- }
- break;
- case "exit":
- isOpen = false;
- break;
- default:
- Console.WriteLine("Неизвестная команда");
- break;
- }
- Console.ReadKey();
- Console.Clear();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement