Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace CSLightFirst
- {
- class Program
- {
- static void Main()
- {
- bool isExit = false;
- int[] data = new int[1];
- int currentIndex = 0;
- string userInput;
- while (!isExit)
- {
- Console.Write("Введите число или команду (sum и exit): ");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "sum":
- Console.WriteLine($"\nСумма массива: {data.Sum()}\n");
- break;
- case "exit":
- isExit = true;
- break;
- default:
- if (currentIndex > data.Length - 1)
- {
- int[] temp = new int[data.Length + 3];
- for (int i = 0; i < data.Length; i++)
- temp[i] = data[i];
- temp[currentIndex] = int.Parse(userInput);
- data = temp;
- currentIndex++;
- }
- else
- {
- data[currentIndex] = int.Parse(userInput);
- currentIndex++;
- }
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement