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 Арсенал
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] ElMas = new string[0];
- do
- {
- Console.Clear();
- Console.WriteLine("1 - Добавить\n2 - Вывести\n3 - Удалить\n4 - Переместить\n5 - Выход\n");
- int N = Convert.ToInt32(Console.ReadLine());
- switch (N)
- {
- case 1:
- Console.Clear();
- Console.WriteLine("Добавление\n");
- Console.WriteLine("Введите новый элемент\n");
- string NewEl = Console.ReadLine();
- string[] Nresult = new string[ElMas.Length + 1];
- for (int i = 0; i < ElMas.Length; i++)
- {
- Nresult[i] = ElMas[i];
- }
- Nresult[Nresult.Length - 1] = NewEl.ToUpper();
- ElMas = Nresult;
- Console.WriteLine();
- Console.WriteLine("Добавлено");
- Console.ReadKey();
- break;
- case 2:
- Console.Clear();
- Console.WriteLine("Вывод\n");
- for (int i = 0; i < ElMas.Length; i++)
- {
- Console.WriteLine(ElMas[i]);
- }
- Console.ReadKey();
- break;
- case 3:
- Console.Clear();
- Console.WriteLine("Удаление\n");
- int newLength = ElMas.Length;
- if (newLength < 1)
- {
- Console.WriteLine("Список пуст\n");
- }
- else
- {
- Console.WriteLine("Введите номер элемента\n");
- int NomUd = Convert.ToInt32(Console.ReadLine());
- string[] Oresult = new string[newLength];
- int newCounter = 0;
- for (int i = 0; i < ElMas.Length; i++)
- {
- if (i == NomUd)
- {
- continue;
- }
- else
- {
- Oresult[newCounter] = ElMas[i];
- newCounter += 1;
- }
- }
- ElMas = Oresult;
- }
- Console.WriteLine();
- Console.WriteLine("Удалено");
- Console.ReadKey();
- break;
- case 4:
- Console.Clear();
- Console.WriteLine("Замена\n");
- Console.WriteLine("Какие элементы поменять местами?");
- int N_1 = Convert.ToInt32(Console.ReadLine());
- int N_2 = Convert.ToInt32(Console.ReadLine());
- string Mem = ElMas[N_2];
- ElMas[N_2] = ElMas[N_1];
- ElMas[N_1] = Mem;
- Console.WriteLine("Изменено");
- Console.ReadKey();
- break;
- case 5:
- Console.Clear();
- Console.WriteLine("Выход");
- Console.ReadKey();
- return;
- default:
- Console.Clear();
- Console.WriteLine("Ошибка");
- Console.ReadKey();
- break;
- }
- } while (true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement