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[] fullNames = new string[0];
- string[] positions = 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":
- AddElement(ref fullNames, ref positions);
- break;
- case "2":
- ShowLists(fullNames, positions, "Список досье :");
- break;
- case "3":
- DeleteElements(ref fullNames,ref positions);
- break;
- case "4":
- SearchSurname(fullNames, positions);
- break;
- case "5":
- exit = true;
- break;
- }
- }
- }
- static void AddElement(ref string[] fullName, ref string[] position)
- {
- string[] tempFullName = new string[fullName.Length + 1];
- string[] tempPosition = new string[position.Length + 1];
- for (int i = 0; i < fullName.Length; i++)
- {
- tempFullName[i] = fullName[i];
- tempPosition[i] = position[i];
- }
- Console.WriteLine("Добавить ФИО :");
- string newFullName = Convert.ToString(Console.ReadLine());
- tempFullName[tempFullName.Length - 1] = newFullName;
- fullName = tempFullName;
- Console.WriteLine("Добавить должность :");
- string newPosition = Convert.ToString(Console.ReadLine());
- tempPosition[tempPosition.Length - 1] = newPosition;
- position = tempPosition;
- }
- static void ShowLists(string[] fullNames, string[] positions, string text)
- {
- Console.WriteLine(text);
- int indent = 1;
- for (int i = 0; i < fullNames.Length; i++)
- {
- Console.WriteLine((i + indent) + ") " + fullNames[i] + " - " + positions[i] + ".");
- }
- }
- static void DeleteElements(ref string[] fullName, ref string[] position)
- {
- int number = Convert.ToInt32(Console.ReadLine());
- DeleteElement(ref number, ref fullName);
- DeleteElement(ref number, ref position);
- }
- static void SearchSurname(string[] fullNames, string[] positions)
- {
- Console.WriteLine("Введите фамилию :");
- string surname = Console.ReadLine();
- for (int i = 0; i < fullNames.Length; i++)
- {
- string[] words = fullNames[i].Split(' ');
- if (words[0] == surname)
- {
- Console.WriteLine(fullNames[i] + " - " + positions[i]);
- }
- else
- {
- Console.WriteLine("Такого в списке нету.");
- }
- }
- }
- static void DeleteElement(ref int number , ref string[] element)
- {
- if (number <= element.Length)
- {
- string[] tempElement = new string[element.Length - 1];
- for (int i = number - 1; i < element.Length - 1; i++)
- {
- element[i] = element[i + 1];
- }
- for (int i = 0; i < element.Length - 1; i++)
- {
- tempElement[i] = element[i];
- }
- element = tempElement;
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment