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)
- {
- int[] array = new int[0];
- string command;
- bool isOpen = true;
- while (isOpen)
- {
- Console.Clear();
- Console.WriteLine("Числа в памяти:");
- foreach (var number in array)
- {
- Console.Write(number + " ");
- }
- Console.Write("\n\nВведите или число, или команды sum, exit - ");
- command = Console.ReadLine();
- switch (command)
- {
- case "sum":
- int sum = 0;
- foreach (var number in array)
- {
- Console.Write(number + "+");
- sum += number;
- }
- Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
- Console.Write("=" + sum);
- break;
- case "exit":
- isOpen = false;
- break;
- default:
- int temp = Convert.ToInt32(command);
- int[] tempArray = new int[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- array = tempArray;
- array[array.Length - 1] = temp;
- break;
- }
- Console.ReadKey();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement