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":
- AddElements(ref fullNames, ref positions);
- break;
- case "2":
- ShowLists(fullNames, positions, "Список досье :");
- break;
- case "3":
- DeleteDossier(ref fullNames, ref positions);
- break;
- case "4":
- SearchSurname(fullNames, positions);
- break;
- case "5":
- exit = true;
- break;
- }
- }
- }
- static void AddElements(ref string[] fullNames, ref string[] positions)
- {
- AddElement(ref fullNames,"Добавить ФИО :");
- AddElement(ref positions,"Добавить должность :");
- }
- 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 DeleteDossier(ref string[] fullNames, ref string[] positions)
- {
- int number = Convert.ToInt32(Console.ReadLine());
- DeleteElement(number, ref fullNames);
- DeleteElement(number, ref positions);
- }
- 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]);
- }
- }
- }
- static void DeleteElement(int number, ref string[] element)
- {
- if (0< number && number <= element.Length)
- {
- string[] tempElement = new string[element.Length - 1];
- for (int i = number - 1; i < element.Length - 1; i++)
- {
- element[i] = element[i + 1];
- }
- for (int i = 0; i < element.Length - 1; i++)
- {
- tempElement[i] = element[i];
- }
- element = tempElement;
- }
- }
- static void AddElement(ref string[] element,string text)
- {
- string[] tempElement = new string[element.Length + 1];
- for (int i = 0; i < element.Length; i++)
- {
- tempElement[i] = element[i];
- }
- Console.WriteLine(text);
- string newElement = Convert.ToString(Console.ReadLine());
- tempElement[tempElement.Length - 1] = newElement;
- element = tempElement;
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment