Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace egor
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool isOpen = true;
- string[] fullName = { "Обанин Виталий Андреевичь", "Киревичев Егор Николаевичь", "Гордиевских Виктория Андреевна" };
- string[] position = { "Програмист", "Повар", "Маркетолог" };
- string userInput;
- while (isOpen == true)
- {
- Console.WriteLine("1 - Добавить досье.\n2 - Вывести все досье.\n3 - Удолить досье.\n4 - Поиск по фамилии.\n5 - Выход");
- Console.WriteLine("Введите номер команды.");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "1":
- Console.Write("Введите ФИО: ");
- userInput = Console.ReadLine();
- IncreaseArray(ref fullName, userInput);
- Console.Write("Введите должность: ");
- userInput = Console.ReadLine();
- ExpandArray(ref position, userInput);
- break;
- case "2":
- WithdrawAllDossiers(fullName, position);
- break;
- case "3":
- for (int i = 0; i < fullName.Length; i++)
- {
- Console.Write((i + 1) + "." + fullName[i]);
- Console.Write(" " + position[i]);
- if (fullName.Length - 1 != i)
- {
- Console.Write(" - ");
- }
- }
- Console.WriteLine("\nВведите номер досье которое хотите удалить. ");
- int removableDossiers = Convert.ToInt32(Console.ReadLine()) - 1;
- LessenArray(ref fullName, removableDossiers);
- LessenArray(ref position, removableDossiers);
- break;
- case "4":
- SearchByLastName(fullName, position);
- break;
- case "5":
- isOpen = false;
- break;
- }
- }
- }
- static void IncreaseArray(ref string[] receivedArray, string userInput)
- {
- string[] tempReceivedArray = new string[receivedArray.Length + 1];
- for (int i = 0; i < receivedArray.Length; i++)
- {
- tempReceivedArray[i] = receivedArray[i];
- }
- tempReceivedArray[tempReceivedArray.Length - 1] = userInput;
- receivedArray = tempReceivedArray;
- }
- static void WithdrawAllDossiers(string[] fullName, string[] position)
- {
- for (int i = 0; i < fullName.Length; i++)
- {
- Console.Write((i + 1) + "." + fullName[i]);
- Console.Write(" " + position[i]);
- if (fullName.Length - 1 != i)
- {
- Console.Write(" - ");
- }
- }
- Console.WriteLine();
- }
- static void LessenArray(ref string[] receivedArray, int removableDossiers)
- {
- string[] tempReceivedArray = new string[receivedArray.Length - 1];
- for (int i = 0; i < removableDossiers; i++)
- {
- tempReceivedArray[i] = receivedArray[i];
- }
- for (int i = removableDossiers; i < tempReceivedArray.Length; i++)
- {
- tempReceivedArray[i] = receivedArray[i + 1];
- }
- receivedArray = tempReceivedArray;
- }
- static void SearchByLastName(string[] fullName, string[] position)
- {
- bool isOpen = true;
- string userUnput = Console.ReadLine(); ;
- string surname = "";
- while (isOpen == true)
- {
- for (int i = 0; i < fullName.Length - 1; i++)
- {
- string a = fullName[i];
- for (int j = 0; j < a.Length - 1; j++)
- {
- if (a[j] == ' ')
- {
- break;
- }
- surname += Convert.ToString(a[j]);
- }
- if (userUnput == surname)
- {
- Console.WriteLine(fullName[i] + " - " + position[i]);
- isOpen = false;
- }
- else if (i == fullName.Length - 1)
- {
- Console.WriteLine("Такой фамилии нет");
- isOpen = false;
- }
- surname = "";
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment