Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StartCode]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp11
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string[] fullNames = new string[0];
- string[] positions = new string[0];
- string menuOption;
- bool exit = false;
- while (exit == false)
- {
- Console.WriteLine(" МЕНЮ");
- Console.WriteLine();
- Console.WriteLine("1 - Добавить досье.\n2 - Список досье.\n3 - Удалить досье.\n4 - Поиск по фамилии.\n5 - Выход.");
- menuOption = Console.ReadLine();
- switch (menuOption)
- {
- case "1":
- AddElement(ref fullNames, "Добавить ФИО :");
- AddElement(ref positions, "Добавить должность :");
- break;
- case "2":
- ShowLists(fullNames,positions ,"Список досье :");
- break;
- case "3":
- DeleteElement(ref fullNames, ref positions);
- break;
- case "4":
- SearchSurname(fullNames,positions);
- break;
- case "5":
- exit = true;
- break;
- }
- }
- }
- static void AddElement(ref string[] array, string text)
- {
- string[] tempArray = new string[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- Console.WriteLine(text);
- string newArray = Convert.ToString(Console.ReadLine());
- tempArray[tempArray.Length - 1] = newArray;
- array = tempArray;
- }
- static void ShowLists( string[] fullNames, string[] positions, string text)
- {
- Console.WriteLine(text);
- int indent = 1;
- for (int i = 0; i < fullNames.Length; i++)
- {
- Console.WriteLine((i + indent) + ") " + fullNames[i] + " - " + positions[i] + ".");
- }
- }
- static void DeleteElement(ref string[] fullName, ref string[] position)
- {
- int number = Convert.ToInt32(Console.ReadLine());
- if (number <= fullName.Length)
- {
- for (int i = number - 1; i < fullName.Length - 1; i++)
- {
- fullName[i] = fullName[i + 1];
- position[i] = position[i + 1];
- }
- string[] tempFullname = new string[fullName.Length - 1];
- string[] tempPosotion = new string[position.Length - 1];
- for (int i = 0; i < fullName.Length - 1; i++)
- {
- tempFullname[i] = fullName[i];
- tempPosotion[i] = position[i];
- }
- fullName = tempFullname;
- position = tempPosotion;
- }
- else
- {
- Console.WriteLine("Такого в списке нету.");
- }
- }
- static void SearchSurname(string[] fullNames, string[] positions)
- {
- Console.WriteLine("Введите фамилию :");
- string surname = Console.ReadLine();
- for (int i = 0; i < fullNames.Length; i++)
- {
- string[] words = fullNames[i].Split(' ');
- if (words[0] == surname)
- {
- Console.WriteLine(fullNames[i] + " - " + positions[i]);
- }
- else
- {
- Console.WriteLine("Такого в списке нету.");
- }
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment