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[] fio = new string[0];
- string[] position = new string[0];
- string userInput;
- int dossierNumber;
- 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.WriteLine("Добавляем...");
- Console.Write("Введите ФИО: ");
- userInput = Console.ReadLine();
- fio = FillDossier(fio, userInput);
- Console.Write("Введите должность: ");
- userInput = Console.ReadLine();
- position = FillDossier(position, userInput);
- break;
- case 2:
- Console.WriteLine("Выводим...");
- if (fio.Length == 0)
- {
- Console.WriteLine("Пусто!");
- }
- else
- {
- for (int i = 0; i < fio.Length && i < position.Length; i++)
- {
- Console.WriteLine("№" + (i + 1) + " " + fio[i] + "-" + position[i]);
- }
- }
- break;
- case 3:
- Console.Write("Удаляем досье под номером: №");
- dossierNumber = Convert.ToInt32(Console.ReadLine());
- if(dossierNumber > fio.Length || dossierNumber < 1)
- {
- Console.WriteLine("Номер досье не существует!");
- break;
- }
- DeleteDossier(ref fio, ref position, (dossierNumber - 1));
- Console.WriteLine("Удаляем...");
- break;
- case 4:
- Console.WriteLine("Введите фамилию:");
- userInput = Console.ReadLine();
- SearchInfo(fio, userInput);
- break;
- case 5:
- Console.WriteLine("Выход...");
- isWorking = false;
- break;
- default:
- Console.WriteLine("Ошибка, повторно введите команду");
- break;
- }
- }
- }
- static string[] FillDossier(string[] fio, string userInput)
- {
- string[] tempFio = new string[fio.Length + 1];
- for(int i = 0; i < fio.Length; i++ )
- {
- tempFio[i] = fio[i];
- }
- tempFio[tempFio.Length - 1] = userInput;
- fio = tempFio;
- return fio;
- }
- static string[] FillPosition(string[] position, string userInput)
- {
- string[] tempPos = new string[position.Length + 1];
- for(int i = 0; i < position.Length; i++)
- {
- tempPos[i] = position[i];
- }
- tempPos[tempPos.Length - 1] = userInput;
- position = tempPos;
- return position;
- }
- static void DeleteDossier(ref string[] fio, ref string[] position, int userNumbers)
- {
- string[] tempFio = new string[fio.Length - 1];
- string[] tempPosition = new string[position.Length - 1];
- for (int i = 0; i < fio.Length && i < position.Length; i++)
- {
- if (i < userNumbers)
- {
- tempFio[i] = fio[i];
- tempPosition[i] = position[i];
- }
- else if (i > userNumbers)
- {
- tempFio[i - 1] = fio[i];
- tempPosition[i - 1] = position[i];
- }
- }
- fio = tempFio;
- position = tempPosition;
- }
- static void SearchInfo(string[] fio, string userInput)
- {
- for(int i = 0; i < fio.Length; i++)
- {
- if(userInput == fio[i])
- {
- Console.WriteLine("Досье найдено: " + fio[i]);
- return;
- }
- }
- Console.WriteLine("Досье не найдено...");
- }
- }
- }
Add Comment
Please, Sign In to add comment