Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] personalData = new string[0];
- string[] arrayPost = new string[0];
- string[] numberToFami = new string[0];
- bool exit = true;
- while (exit)
- {
- Console.SetCursorPosition(30, 0);
- Console.WriteLine("Базза данных");
- Console.WriteLine("Список комманд:\n");
- Console.WriteLine(" 1)Добавить досье");
- Console.WriteLine(" 2)Вывести досье");
- Console.WriteLine(" 3)Удалить досье");
- Console.WriteLine(" 4)Поиск по фамилии");
- Console.WriteLine(" 5)Выйти");
- Console.Write("Введите номер комманды:");
- int numberCommand = Convert.ToInt32(Console.ReadLine());
- switch (numberCommand)
- {
- case 1:
- Console.Write("Введите имя\nИмя:");
- string name = Console.ReadLine();
- Console.Write("Введите фамилию\nФамилия:");
- string fami = Console.ReadLine();
- Console.Write("Введите отчество\nОтчество:");
- string patronymic = Console.ReadLine();
- Console.Write("Введите должность\nДолжность:");
- string post = Console.ReadLine();
- addDossier(ref personalData, name, fami, patronymic);
- addPost(ref arrayPost, post);
- addSeekNumberByFami(ref numberToFami, fami);
- break;
- case 2:
- for (int i = 0; i < personalData.Length; i++)
- {
- Console.WriteLine("#" + (i + 1) + " " + personalData[i] + " " + arrayPost[i]);
- }
- break;
- case 3:
- Console.Write("Введите номер досье:");
- int numberDpssierDelete = Convert.ToInt32(Console.ReadLine()) - 1;
- deleteElementArray(ref numberToFami, numberDpssierDelete);
- deleteElementArray(ref personalData, numberDpssierDelete);
- deleteElementArray(ref arrayPost, numberDpssierDelete);
- break;
- case 4:
- Console.Write("Введите фамилию\n Фамилия:");
- string searchByFami = Console.ReadLine();
- for (int i = 0; i < numberToFami.Length; i++)
- {
- if (numberToFami[i] == searchByFami)
- {
- Console.WriteLine(personalData[i]+arrayPost[i]);
- break;
- }
- if (i == numberToFami.Length - 1)
- {
- Console.WriteLine("Нет досье с введённой фамилией...");
- }
- }
- break;
- case 5:
- exit = false;
- break;
- default:
- Console.Write("Вы ввели неправильный номер комманды...");
- break;
- }
- Console.ReadLine();
- Console.Clear();
- }
- }
- static void addDossier(ref string[] addArray, string name, string fami, string patronymic)
- {
- string[] array = new string[addArray.Length + 1];
- for (int i = 0; i < addArray.Length; i++)
- {
- array[i] = addArray[i];
- }
- array[addArray.Length] = ($"{fami} {name} {patronymic}. Должность - ");
- addArray = array;
- }
- static void addPost(ref string[] addArray, string post)
- {
- string[] array = new string[addArray.Length + 1];
- for (int i = 0; i < addArray.Length; i++)
- {
- array[i] = addArray[i];
- }
- array[addArray.Length] = post;
- addArray = array;
- }
- static void addSeekNumberByFami(ref string[] addArray, string fami)
- {
- string[] array = new string[addArray.Length + 1];
- for (int i = 0; i < addArray.Length; i++)
- {
- array[i] = addArray[i];
- }
- array[addArray.Length] = fami;
- addArray = array;
- }
- static void deleteElementArray(ref string[] arrayDelete, int numberDelete)
- {
- string[] arrayEditor = arrayDelete;
- string[] arrayDeleteIndex = new string[arrayDelete.Length - 1];
- for (int i = numberDelete; i < arrayEditor.Length - 1; i++)
- {
- arrayEditor[i] = arrayEditor[i + 1];
- }
- for (int i = 0; i < arrayDeleteIndex.Length; i++)
- {
- arrayDeleteIndex[i] = arrayEditor[i];
- }
- arrayDelete = arrayDeleteIndex;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement