Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [StartCode]
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp11
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string[] fullName = new string[0];
- string[] position = new string[0];
- string menuOption;
- bool exit = false;
- while (exit == false)
- {
- Console.WriteLine(" МЕНЮ");
- Console.WriteLine();
- Console.WriteLine("1 - Добавить досье.\n2 - Список досье.\n3 - Удалить досье.\n4 - Поиск по фамилии.\n5 - Выход.");
- menuOption = Console.ReadLine();
- switch (menuOption)
- {
- case "1":
- AddList(ref fullName, "Добавить ФИО :");
- AddList(ref position, "Добавить должность :");
- break;
- case "2":
- ShowLists(fullName,position ,"Список досье :");
- break;
- case "3":
- int number = Convert.ToInt32(Console.ReadLine());
- DeleteList(number ,ref fullName);
- DeleteList(number ,ref position);
- break;
- case "4":
- string surname = Console.ReadLine();
- SearchSurname(fullName,position,surname);
- break;
- case "5":
- exit = true;
- break;
- }
- }
- }
- static void AddList(ref string[] people, string text)
- {
- string[] tempPeople = new string[people.Length + 1];
- for (int i = 0; i < people.Length; i++)
- {
- tempPeople[i] = people[i];
- }
- Console.WriteLine(text);
- string newPeople = Convert.ToString(Console.ReadLine());
- tempPeople[tempPeople.Length - 1] = newPeople;
- people = tempPeople;
- }
- static void ShowLists( string[] fullName, string[] position, string text)
- {
- Console.WriteLine(text);
- for (int i = 0; i < fullName.Length; i++)
- {
- int indent = 1;
- Console.WriteLine((i + indent) + ") " + fullName[i] + " - " + position[i] + ".");
- }
- }
- static void DeleteList(int number, ref string[] people )
- {
- for (int i = number - 1; i < people.Length - 1; i++)
- {
- people[i] = people[i + 1];
- }
- string[] tempPeople = new string[people.Length - 1];
- for (int i = 0; i < people.Length - 1; i++)
- {
- tempPeople[i] = people[i];
- }
- people = tempPeople;
- }
- static void SearchSurname(string[] fullName, string[] position, string surname)
- {
- for (int i = 0; i < fullName.Length; i++)
- {
- string[] words = fullName[i].Split(' ');
- for (int j = 0; j < words.Length; j++)
- {
- if (words[j] == surname)
- {
- Console.WriteLine(fullName[i] + " - " + position[i]);
- }
- }
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment