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 ConsoleApp12
- {
- class Program
- {
- static void Main(string[] args)
- {
- String userInput = "";
- int i = 0;
- int[] array = new int[0];
- Console.WriteLine("Введите цифры");
- do
- {
- userInput = Console.ReadLine();
- if (userInput == "sum") break;
- int arrayElement = int.Parse(userInput);
- int[] tempArray = new int[array.Length + 1];
- for (i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- tempArray[tempArray.Length - 1] = arrayElement;
- array= tempArray;
- }
- while (true);
- Console.WriteLine("Сумма: ");
- int sum = 0;
- for (int j = 0; j < array.Length; j++)
- {
- sum += array[j];
- }
- Console.WriteLine(sum);
- userInput = Console.ReadLine();
- if (userInput == "sort")
- {
- Array.Sort(array);
- Array.Reverse(array);
- Console.WriteLine();
- for (int p = 0; p < array.Length; p++)
- {
- Console.Write(array[p] + " ");
- }
- }
- //
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement