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];
- string command;
- int sum =0 ;
- int[] tempBag = new int[bag.Length + 1];
- bool open = (true);
- while (open == true)
- {
- Console.WriteLine("Введите команду :");
- command = Console.ReadLine();
- tempBag = new int[bag.Length + 1];
- switch (command)
- {
- case "exit":
- open = false;
- break;
- case "sum":
- Console.WriteLine(sum);
- break;
- default:
- for (int i = 0; i < bag.Length; i++)
- {
- tempBag[i] = bag[i];
- }
- tempBag[tempBag.Length - 1] = Convert.ToByte(command);
- bag = tempBag;
- sum += bag[bag.Length - 1];
- continue;
- }
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment