Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSLight3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[0];
- int summ = 0;
- string input;
- while (true)
- {
- input = Console.ReadLine();
- switch (input)
- {
- case "sum":
- for (int i = 0; i < array.Length; i++)
- {
- summ += array[i];
- }
- Console.WriteLine("Сумма введенных чисел равна: " + summ);
- summ = 0;
- break;
- case "exit":
- Environment.Exit(0);
- break;
- default:
- 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(input);
- array = tempArray;
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement