Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Кадровый_Учет
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool isWorking = true;
- string[] fullName = new string[0];
- string[] position = new string[0];
- while (isWorking)
- {
- Console.WriteLine("\nМеню:\n" +
- "1) добавить досье;\n" +
- "2) вывести все досье\n" +
- "3) удалить досье\n" +
- "4) поиск по фамилии\n" +
- "5) выход");
- Console.Write("\nВвод: ");
- switch (Convert.ToInt32(Console.ReadLine()))
- {
- case 1:
- Console.Write("Введите ФИО: ");
- fullName = AddDossier(fullName);
- Console.Write("Введите должность: ");
- position = AddDossier(position);
- break;
- case 2:
- PrintInfo(fullName, position);
- break;
- case 3:
- DeleteDossier(ref fullName, ref position);
- break;
- case 4:
- FindDossierByFullname(fullName, position);
- break;
- case 5:
- Console.WriteLine("Выход...");
- isWorking = false;
- break;
- default:
- Console.WriteLine("Ошибка, повторно введите команду");
- break;
- }
- }
- }
- static string[] AddDossier(string[] array)
- {
- string userInput = Console.ReadLine();
- string[] tempArray = new string[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- tempArray[tempArray.Length - 1] = userInput;
- array = tempArray;
- return array;
- }
- static void ChangeDossier(ref string[] array, int dossierNumber)
- {
- string[] tempArray = new string[array.Length - 1];
- for (int i = 0; i < array.Length; i++)
- {
- if (i < dossierNumber)
- {
- tempArray[i] = array[i];
- }
- else if (i > dossierNumber)
- {
- tempArray[i - 1] = array[i];
- }
- }
- array = tempArray;
- }
- static void DeleteDossier(ref string[] fullName, ref string[] position)
- {
- Console.Write("Удаляем досье под номером: №");
- int dossierNumber = Convert.ToInt32(Console.ReadLine()) - 1;
- if (dossierNumber >= fullName.Length || dossierNumber < 0)
- {
- Console.WriteLine("Номер досье не существует!");
- }
- else
- {
- Console.WriteLine("Удаляем...");
- ChangeDossier(ref fullName, dossierNumber);
- ChangeDossier(ref position, dossierNumber);
- }
- }
- static void FindDossierByFullname(string[] fullname, string[] position)
- {
- Console.WriteLine("Введите фамилию:");
- string userInput = Console.ReadLine();
- for (int i = 0; i < fullname.Length; i++)
- {
- if (userInput == fullname[i])
- {
- Console.WriteLine("Досье найдено: " + fullname[i] + " - " + position[i]);
- return;
- }
- }
- Console.WriteLine("Досье не найдено...");
- }
- static void PrintInfo(string[] fullName, string[] position)
- {
- if (fullName.Length == 0)
- {
- Console.WriteLine("Пусто!");
- }
- else
- {
- for (int i = 0; i < fullName.Length; i++)
- {
- Console.WriteLine("№" + (i + 1) + " " + fullName[i] + " - " + position[i]);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment