Created
October 4, 2021 10:56
-
-
Save Ana19997/3604a18ce4beb0804201c04421927557 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]; | |
Console.WriteLine("Введите элемент массива"); | |
while (userInput != "exit") | |
{ | |
userInput = Console.ReadLine(); | |
switch (userInput) | |
{ | |
case "sum": | |
int sum = 0; | |
Console.WriteLine(String.Format("Сумма элементов = {0}", Data.Sum())); | |
break; | |
case "exit": | |
return; | |
default: | |
int result; | |
if (int.TryParse(userInput, out result)) | |
Data = Data.Concat(new int[] { result }).ToArray(); | |
break; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment