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":
- Console.Write("Какое досье удалить? :");
- int number =Convert.ToInt32(Console.ReadLine());
- deleteList(number,ref fullName);
- deleteList(number,ref position);
- break;
- case "4":
- Console.WriteLine("Поиск по фамилии : ");
- string surname;
- surname = Console.ReadLine();
- searchSurname(fullName,position,surname);
- break;
- case "5":
- exit = true;
- break;
- }
- }
- }
- static void addList(ref string[] x, string text)
- {
- string[] tempX = new string[x.Length + 1];
- for (int i = 0; i < x.Length; i++)
- {
- tempX[i] = x[i];
- }
- Console.WriteLine(text);
- string newX = Convert.ToString(Console.ReadLine());
- tempX[tempX.Length - 1] = newX;
- x = tempX;
- }
- static void showLists( string[]x,string[]y,string text)
- {
- Console.WriteLine(text);
- for (int i = 0; i < x.Length; i++)
- {
- int indent = 1;
- Console.WriteLine((i + indent) + ") " + x[i] + " - " + y[i] + ".");
- }
- }
- static void deleteList(int x,ref string[] y)
- {
- for (int i = x - 1; i < y.Length - 1; i++)
- {
- y[i] = y[i + 1];
- }
- string[] tempY = new string[y.Length - 1];
- for (int i = 0; i < y.Length - 1; i++)
- {
- tempY[i] = y[i];
- }
- y = tempY;
- }
- static void searchSurname(string[] x,string[]y,string z)
- {
- for (int i = 0; i < x.Length; i++)
- {
- string[] words = x[i].Split(' ');
- for (int j = 0; j < words.Length; j++)
- {
- if (words[j] == z)
- {
- Console.WriteLine(x[i] + " - " + y[i]);
- }
- }
- }
- }
- }
- }
- [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment