Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StartCode]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int[] bag =new int[1];
- bool beOpen = (true);
- while (beOpen == true)
- {
- string command;
- Console.WriteLine("Введите команду :");
- command = Console.ReadLine();
- switch (command)
- {
- case "exit":
- beOpen = false;
- break;
- case "sum":
- int sum = 0;
- bag[0] = 0;
- for(int i = 1; i < bag.Length; i++)
- {
- sum+=bag[i];
- }
- Console.WriteLine(sum);
- break;
- default:
- int[] tempBag = new int[bag.Length + 1];
- for (int i = 0; i < bag.Length; i++)
- {
- tempBag[i] = bag[i];
- }
- tempBag[tempBag.Length - 1] = Convert.ToByte(command);
- bag = tempBag;
- continue;
- }
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment