Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading.Tasks;
- namespace CSharpLight
- {
- public static class Program
- {
- public static void Main()
- {
- int[] array = new int[0];
- bool exit = false;
- string text = "Sum - сумма введеных чисел\nExit - выход";
- Console.WriteLine(text);
- while (exit == false)
- {
- Console.Write("Введите число: ");
- string input = Console.ReadLine();
- if (input.ToLower() == "sum")
- {
- int arraySum = 0;
- for (int i = 0; i < array.Length; i++)
- {
- arraySum += array[i];
- }
- Console.WriteLine("Сумма: " + arraySum);
- }
- else if (input.ToLower() == "exit")
- {
- exit = true;
- }
- else if (int.TryParse(input, out int number))
- {
- int[] tempArray = new int[array.Length + 1];
- tempArray[tempArray.Length - 1] = int.Parse(input);
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- array = tempArray;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment