Created
October 4, 2021 17:18
-
-
Save Ana19997/5798acc9440e203049a5b40b20e07ba7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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