Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StartCode]
- using System;
- namespace ConsoleApp14
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string userInput;
- int[] array = new int[0];
- bool isWork = true;
- while (isWork)
- {
- Console.WriteLine("Введите команду : цифру , sum или exit.");
- userInput = Console.ReadLine();
- if (userInput == "sum")
- {
- int sumNumber = 0;
- for (int i = 0; i < array.Length; i++)
- {
- sumNumber += array[i];
- }
- Console.WriteLine(sumNumber);
- }
- else if (userInput == "exit")
- {
- isWork = false;
- }
- else
- {
- int[] temporaryArray = new int[array.Length +1];
- temporaryArray[array.Length ] = Convert.ToInt32(userInput);
- for(int i = 0; i < array.Length; i++)
- {
- temporaryArray[i] = array[i];
- }
- array = temporaryArray;
- }
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment