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 ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] list = new int[0];
- bool start = true;
- string userInput;
- int summ = 0;
- Console.WriteLine("Вводите числа и как только введете summ посчитают все числа,sort выведет все числа в порядке уменьшения");
- while (start == true)
- {
- userInput = Console.ReadLine();
- if (userInput == "summ")
- {
- for (int i = 0; i < list.Length; i++)
- {
- summ += list[i];
- }
- Console.WriteLine("Сумма введеных вами чисел равна: " + summ);
- }
- else if (userInput == "sort")
- {
- int temp;
- for (int i = 0; i < list.Length; i++)
- {
- for (int j = i + 1; j < list.Length; j++)
- {
- if (list[i] > list[j])
- {
- temp = list[i];
- list[i] = list[j];
- list[j] = temp;
- }
- }
- }
- Console.WriteLine("После сортировки:");
- for (int i = 0; i < list.Length; i++)
- {
- Console.WriteLine(list[i]);
- }
- }
- else{
- int[] templist = new int[list.Length + 1];
- for (int j = 0; j < list.Length; j++)
- {
- templist[j] = list[j];
- }
- templist[templist.Length - 1] = Convert.ToInt32(userInput);
- list = templist;
- }
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement