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:
- DisplayInfo(fullName, position);
- break;
- case 3:
- DeleteDossier(ref fullName, ref position);
- break;
- case 4:
- SearchInfo(fullName, position);
- break;
- case 5:
- Console.WriteLine("Выход...");
- isWorking = false;
- break;
- default:
- Console.WriteLine("Ошибка, повторно введите команду");
- break;
- }
- }
- }
- static string[] AddDossier(string[] info)
- {
- string userInput = Console.ReadLine();
- string[] temInfo = new string[info.Length + 1];
- for(int i = 0; i < info.Length; i++)
- {
- temInfo[i] = info[i];
- }
- temInfo[temInfo.Length - 1] = userInput;
- info = temInfo;
- return info;
- }
- static void DeleteDossier(ref string[] fullName, ref string[] position)
- {
- Console.Write("Удаляем досье под номером: №");
- int dossierNumber = Convert.ToInt32(Console.ReadLine()) - 1;
- if (dossierNumber> fullName.Length)
- {
- Console.WriteLine("Номер досье не существует!");
- }
- else
- {
- Console.WriteLine("Удаляем...");
- string[] tempFullname = new string[fullName.Length - 1];
- string[] tempPosition = new string[position.Length - 1];
- for (int i = 0; i < fullName.Length; i++)
- {
- if (i < dossierNumber)
- {
- tempFullname[i] = fullName[i];
- tempPosition[i] = position[i];
- }
- else if (i > dossierNumber)
- {
- tempFullname[i - 1] = fullName[i];
- tempPosition[i - 1] = position[i];
- }
- }
- fullName = tempFullname;
- position = tempPosition;
- }
- }
- static void SearchInfo(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 DisplayInfo(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