Advertisement
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 ConsoleApp26
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[1];
- string stroke;
- bool isWork = true;
- int summ = 0;
- Console.WriteLine("Введите числа или команду\n summ - Найти сумму введёных чисел\n exit - выход из программы");
- while (isWork)
- {
- int[] tempArray = new int[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- stroke = Console.ReadLine();
- if (stroke == "exit")
- {
- isWork = false;
- }
- else if (stroke == "summ")
- {
- for (int i = 0; i < array.Length; i++)
- {
- summ += array[i];
- }
- Console.WriteLine("Сумма равна");
- Console.WriteLine(summ);
- }
- else
- {
- tempArray[tempArray.Length - 1] = Convert.ToInt32(stroke);
- }
- array = tempArray;
- summ = 0;
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement