Skip to content

Instantly share code, notes, and snippets.

@Ana19997
Created October 4, 2021 17:18
Show Gist options
  • Save Ana19997/5798acc9440e203049a5b40b20e07ba7 to your computer and use it in GitHub Desktop.
Save Ana19997/5798acc9440e203049a5b40b20e07ba7 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace сум
{
class Program
{
static void Main(string[] args)
{
string userInput = "";
int[] data = new int[0];
int[] increase = new int[data.Length + 1];
Console.WriteLine("Введите элемент массива");
while (userInput != "exit")
{
userInput = Console.ReadLine();
switch (userInput)
{
case "sum":
int sum = 0;
for (int i = 0; i < data.Length; i++)
{
sum += data[i];
Console.WriteLine("Сумма введённых чисел равна " + sum);
}
break;
case "exit":
return;
default:
for(int i = 0; i < data.Length; i++)
{
increase[i] = data[i];
}
data = increase;
break;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment