Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[0];
- bool cycleWork = true;
- while (cycleWork)
- {
- int sum = 0;
- string userInput = Console.ReadLine();
- if (userInput == "exit")
- {
- cycleWork = false;
- }
- else if (userInput == "sum")
- {
- for (int i = 0; i < array.Length; i++)
- {
- sum += array[i];
- }
- Console.WriteLine(sum);
- }
- else
- {
- int[] tempArray = new int[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- tempArray[tempArray.Length - 1] = Convert.ToInt32(userInput);
- array = tempArray;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment