Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Hr
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] fullName = { "Беляев Матвей Артёмович", "Блажевич Игорь Юрьевич", "Валиева Руфина Рафаэлевна", "Возвышаев Александр Андреевич", "Гриненко Алексей Алексеевич", "Жигляев Родион Алексеевич" };
- string[] position = { "Event-менеджер", "SEO-оптимизатор", "SMM-менеджер", "Авиадиспетчер", "Адвокат", "Актер" };
- bool exit = false;
- while (!exit)
- {
- Console.WriteLine("Выберите пункт меню:\n1.Добавить досье\n2.Вывести все досье\n3.Удалить досье\n4.Поиск по фамилии\n5.Выход", '-');
- int menu = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine();
- if (menu == 1)
- {
- AddFullNameAndPosition(ref fullName, ref position);
- }
- else if (menu == 2)
- {
- Console.WriteLine("Все досье: ");
- PrintFullNameAndPosition(fullName, position);
- }
- else if (menu == 3)
- {
- if (fullName.Length == 0)
- {
- Console.WriteLine("Нет записей.");
- }
- else
- {
- Console.WriteLine("Выберите досье,которое хотите удалить: ");
- RemoveFullNameAndPosition(ref fullName, ref position);
- }
- }
- else if (menu == 4)
- {
- Console.WriteLine("Напишите фамилию: ");
- SearchFullName(fullName, position);
- }
- else if (menu == 5)
- {
- exit = true;
- }
- else
- {
- Console.WriteLine("Нет такого пункта меню.");
- }
- }
- Console.ReadKey();
- }
- static void AddFullNameAndPosition(ref string[] fullName, ref string[] position)
- {
- string[] tempFullName = new string[fullName.Length + 1];
- string[] tempPosition = new string[position.Length + 1];
- Console.WriteLine("Введите ФИО: ");
- string enterFullName = Console.ReadLine();
- tempFullName[tempFullName.Length - 1] = enterFullName;
- Console.WriteLine("Введите должность: ");
- string enterPosition = Console.ReadLine();
- tempPosition[tempPosition.Length - 1] = enterPosition;
- SetValues(tempFullName, ref fullName, tempPosition, ref position);
- Console.WriteLine();
- }
- static void RemoveFullNameAndPosition(ref string[] fullName, ref string[] position)
- {
- string[] tempRemoveFullname = new string[fullName.Length - 1];
- string[] tempRemovePosition = new string[position.Length - 1];
- PrintFullNameAndPosition(fullName, position);
- int id = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine();
- if (tempRemoveFullname.Length >= id)
- {
- ProcessFullNameAndposition(tempRemoveFullname, ref fullName, tempRemovePosition, ref position, id);
- Console.WriteLine($"Вы удалили досье под номером - {id}");
- }
- else
- {
- Console.WriteLine($"Досье под номером {id} не существует.");
- }
- Console.WriteLine();
- }
- static void SetValues(string[] tempFullName, ref string[] fullName, string[] tempPosition, ref string[] position)
- {
- for (int i = 0; i < fullName.Length; i++)
- {
- tempFullName[i] = fullName[i];
- tempPosition[i] = position[i];
- }
- fullName = tempFullName;
- position = tempPosition;
- }
- static void ProcessFullNameAndposition(string[] tempFullName, ref string[] fullName, string[] tempPosition, ref string[] position, int id)
- {
- for (int i = 0; i < tempFullName.Length; i++)
- {
- if (i < id)
- {
- tempFullName[i] = fullName[i];
- tempPosition[i] = position[i];
- }
- else
- {
- tempFullName[i] = fullName[i + 1];
- tempPosition[i] = position[i + 1];
- }
- }
- fullName = tempFullName;
- position = tempPosition;
- }
- static void PrintFullNameAndPosition(string[] fullName, string[] position)
- {
- for (int i = 0; i < fullName.Length; i++)
- {
- Console.WriteLine($"{i}. {fullName[i]} - {position[i]}");
- }
- Console.WriteLine();
- }
- static void SearchFullName(string[] fullName, string[] position)
- {
- string searchFullName = Console.ReadLine();
- bool isFind = false;
- for (int i = 0; i < fullName.Length; i++)
- {
- if (fullName[i].ToLower() == searchFullName.ToLower())
- {
- Console.WriteLine($"Результат поиска {searchFullName} :");
- Console.WriteLine($"{fullName[i]} - {position[i]}");
- isFind = true;
- }
- }
- if (isFind == false)
- {
- Console.WriteLine("По вашему запросу ничего не найдено.");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement