Created
October 3, 2021 11:28
-
-
Save Ana19997/557f74c1cafbd5d867a02ae56b6a832d 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) | |
{ | |
int sum = 0; | |
string count = "sum"; | |
string exit = "exit"; | |
string userInput = ""; | |
int[] Data = new int[0]; | |
Console.WriteLine("Введите элемент массива"); | |
while (true) | |
{ | |
userInput = Console.ReadLine(); | |
switch (userInput) | |
{ | |
case "sum": | |
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