Advertisement
alexey3017

Untitled

Mar 23rd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Learn1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string[] fullNames = new string[0];
  13.             string[] job = new string[0];
  14.             int userInput;
  15.             bool isActive = true;
  16.  
  17.             while (isActive)
  18.             {
  19.                 Console.WriteLine("Меню:");
  20.                 Console.WriteLine("1 - Добавить досье.\n2 - Вывести все досье.\n3 - Удалить досье.\n4 - Поиск по фамилии.\n5 - Выход");
  21.                 userInput = Convert.ToInt32(Console.ReadLine());
  22.                 switch (userInput)
  23.                 {
  24.                     case 1:
  25.                         Console.Write("Укажите ФИО:");
  26.                         string name = Console.ReadLine();
  27.                         fullNames = AddDossier(fullNames, name);
  28.  
  29.                         Console.Write("Укажите должность:");
  30.                         string position = Console.ReadLine();
  31.                         job = AddDossier(job, position);
  32.                         break;
  33.                     case 2:
  34.                         FormativeOutput(fullNames, job);
  35.                         break;
  36.                     case 3:
  37.                         Console.WriteLine("Какое резюме вы хотите удалить?");
  38.                         int index = Convert.ToInt32(Console.ReadLine());
  39.                         fullNames = DeleteDossier(fullNames, index);
  40.                         job = DeleteDossier(job, index);
  41.                         Console.Write("Резюме успешно удалено");
  42.                         break;
  43.                     case 4:
  44.                         Console.Write("По какой фамилии искать?:");
  45.                         string surname = Console.ReadLine().ToLower();
  46.                         FindDataSurname(fullNames, job, surname);
  47.                         break;
  48.                     case 5:
  49.                         isActive = false;
  50.                         break;
  51.                 }
  52.             }
  53.             Console.WriteLine("До свидания!");
  54.         }
  55.         static string[] AddDossier(string[] array, string data)
  56.         {
  57.             string[] tempName = new string[array.Length + 1];
  58.  
  59.             for (int i = 0; i < array.Length; i++)
  60.             {
  61.                 tempName[i] = array[i];
  62.             }
  63.             tempName[tempName.Length - 1] = data;
  64.             array = tempName;
  65.             return array;
  66.         }
  67.         static void FormativeOutput(string[] fullNames, string[] job)
  68.         {
  69.             int number = 1;
  70.             for (int i = 0; i < fullNames.Length; i++)
  71.             {
  72.                 Console.Write($"{number})");
  73.                 number++;
  74.                 Console.Write(fullNames[i]);
  75.                 Console.Write($" - {job[i]}");
  76.                 Console.WriteLine();
  77.             }
  78.         }
  79.         static string[] DeleteDossier(string[] array, int index)
  80.         {
  81.             index--;
  82.             string[] tempArray = new string[array.Length - 1];
  83.             for (int i = 0; i < index; i++)
  84.             {
  85.                 tempArray[i] = array[i];
  86.             }
  87.             for (int i = index; i < tempArray.Length; i++)
  88.             {
  89.                 tempArray[i] = array[i + 1];
  90.             }
  91.             array = tempArray;
  92.             return array;
  93.  
  94.         }
  95.         static void FindDataSurname(string[] fullNames, string[] job, string surname)
  96.         {
  97.             bool isFind = false;
  98.             for (int i = 0; i < fullNames.Length; i++)
  99.             {
  100.                 if (surname == fullNames[i].ToLower())
  101.                 {
  102.                     Console.WriteLine($"{fullNames[i]} - {job[i]}");
  103.                     isFind = true;
  104.                     break;
  105.                 }
  106.             }
  107.             if (isFind == false)
  108.             {
  109.                 Console.WriteLine("Такого человека нет.");
  110.             }
  111.         }
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement