kwest87

Untitled

Apr 10th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.57 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp11
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string[] fullName = new string[0];
  15.             string[] position = new string[0];
  16.             string menuOption;
  17.             bool exit = false;
  18.  
  19.             while (exit == false)
  20.  
  21.             {
  22.                 Console.WriteLine("        МЕНЮ");
  23.                 Console.WriteLine();
  24.                 Console.WriteLine("1 - Добавить досье.\n2 - Список досье.\n3 - Удалить досье.\n4 - Поиск по фамилии.\n5 - Выход.");
  25.                 menuOption = Console.ReadLine();
  26.  
  27.                 switch (menuOption)
  28.  
  29.                 {
  30.                     case "1":
  31.                         addList(ref fullName, "Добавить ФИО :");
  32.                         addList(ref position, "Добавить должность :");
  33.                         break;
  34.                     case "2":
  35.                         showLists(fullName,position ,"Список досье :");
  36.                         break;
  37.                     case "3":
  38.                         Console.Write("Какое досье удалить? :");
  39.                         int number =Convert.ToInt32(Console.ReadLine());
  40.                         deleteList(number,ref fullName);
  41.                         deleteList(number,ref position);
  42.                         break;
  43.                     case "4":
  44.                         Console.WriteLine("Поиск по фамилии : ");
  45.                         string surname;
  46.                         surname = Console.ReadLine();
  47.                         searchSurname(fullName,position,surname);
  48.                         break;
  49.                     case "5":
  50.                         exit = true;
  51.                         break;
  52.                 }
  53.             }
  54.         }
  55.  
  56.         static void addList(ref string[] x, string text)
  57.         {
  58.             string[] tempX = new string[x.Length + 1];
  59.  
  60.             for (int i = 0; i < x.Length; i++)
  61.             {
  62.                 tempX[i] = x[i];
  63.             }
  64.  
  65.             Console.WriteLine(text);
  66.             string newX = Convert.ToString(Console.ReadLine());
  67.             tempX[tempX.Length - 1] = newX;
  68.             x = tempX;
  69.         }
  70.  
  71.         static void showLists( string[]x,string[]y,string text)
  72.         {
  73.             Console.WriteLine(text);
  74.  
  75.             for (int i = 0; i < x.Length; i++)
  76.             {
  77.                 int indent = 1;
  78.                 Console.WriteLine((i + indent) + ") " + x[i] + " - " + y[i] + ".");
  79.             }
  80.         }
  81.  
  82.         static void deleteList(int x,ref string[] y)
  83.         {
  84.             for (int i = x - 1; i < y.Length - 1; i++)
  85.             {
  86.                 y[i] = y[i + 1];
  87.             }
  88.  
  89.             string[] tempY = new string[y.Length - 1];
  90.  
  91.             for (int i = 0; i < y.Length - 1; i++)
  92.             {
  93.                 tempY[i] = y[i];
  94.             }
  95.  
  96.             y = tempY;
  97.         }
  98.  
  99.         static void searchSurname(string[] x,string[]y,string z)
  100.         {
  101.             for (int i = 0; i < x.Length; i++)
  102.             {
  103.                 string[] words = x[i].Split(' ');
  104.  
  105.                 for (int j = 0; j < words.Length; j++)
  106.                 {
  107.                     if (words[j] == z)
  108.                     {
  109.                         Console.WriteLine(x[i] + " - " + y[i]);
  110.                     }
  111.                 }
  112.             }
  113.         }
  114.     }
  115. }
  116. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment