Advertisement
Vadim_Rogulev

Untitled

Apr 19th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.07 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.  
  7. namespace Кадровый_учет
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] Surname = new string[0];
  14.             string[] Profession = new string[0];
  15.             do
  16.             {
  17.                 Console.Clear();
  18.                 Console.WriteLine("1 - Добавить досье\n2 - Вывести всё досье\n3 - Удалить досье\n4 - Выход\n");
  19.                 int N = Convert.ToInt32(Console.ReadLine());
  20.                 switch (N)
  21.                 {
  22.                     case 1:
  23.                         Console.Clear();
  24.                         Console.WriteLine("Добавление досье\n");
  25.                         Console.WriteLine("Введите новую фамилию\n");
  26.                         string NewSurname = Console.ReadLine();
  27.                         string[] NresultS = new string[Surname.Length + 1];
  28.                         for (int i = 0; i < Surname.Length; i++)
  29.                         {
  30.                             NresultS[i] = Surname[i];
  31.                         }
  32.                         NresultS[NresultS.Length - 1] = NewSurname.ToUpper();
  33.                         Surname = NresultS;
  34.                         //for (int i = 0; i < Surname.Length; i++)
  35.                         //{
  36.                         //    Console.WriteLine(Surname[i]);
  37.                         //}
  38.                         Console.WriteLine();
  39.                         Console.WriteLine("Введите новую профессию\n");
  40.                         string NewProfession = Console.ReadLine();
  41.                         string[] NresultP = new string[Profession.Length + 1];
  42.                         for (int i = 0; i < Profession.Length; i++)
  43.                         {
  44.                           NresultP[i] = Profession[i];
  45.                         }
  46.                         NresultP[NresultP.Length - 1] = NewProfession.ToUpper();
  47.                         Profession = NresultP;
  48.                         //for (int i = 0; i < Profession.Length; i++)
  49.                         //{
  50.                         //Console.WriteLine(Profession[i]);
  51.                         //}
  52.                         Console.WriteLine();
  53.                         Console.WriteLine("Досье добавлено");
  54.                         Console.ReadKey();
  55.                         break;
  56.                     case 2:
  57.                         Console.Clear();
  58.                         Console.WriteLine("Вывод всех досье\n");
  59.                         for (int i = 0; i < Surname.Length; i++)
  60.                         {
  61.                             Console.WriteLine(Surname[i]+" - "+ Profession[i]);
  62.                         }
  63.  
  64.                         Console.ReadKey();
  65.                         break;
  66.                     case 3:
  67.                         Console.Clear();
  68.                         Console.WriteLine("Удаление досье\n");
  69.                         int newLength = Surname.Length;
  70.                         if (newLength < 1)
  71.                         {
  72.                             Console.WriteLine("Список досье пуст\n");
  73.                         }
  74.                         else
  75.                         {
  76.                             Console.WriteLine("Введите фамилию\n");
  77.                             string OldSurname = Console.ReadLine();
  78.                             string[] OresultS = new string[newLength];
  79.                             string[] OresultP = new string[newLength];
  80.                             int newCounter = 0;
  81.                             for (int i = 0; i < Surname.Length; i++)
  82.                             {
  83.                                 if (Surname[i] == OldSurname.ToUpper())
  84.                                 {
  85.                                     continue;
  86.                                 }
  87.                                 else
  88.                                 {
  89.                                     OresultP[newCounter] = Profession[i];
  90.                                     OresultS[newCounter] = Surname[i];
  91.                                     newCounter += 1;
  92.                                 }
  93.  
  94.  
  95.                             }
  96.                             Surname = OresultS;
  97.                             Profession = OresultP;
  98.                         }
  99.                         Console.WriteLine();
  100.                         Console.WriteLine("Досье удалено");
  101.                         Console.ReadKey();
  102.                         break;
  103.                     case 4:
  104.                         Console.Clear();
  105.                         Console.WriteLine("Выход");
  106.                         Console.ReadKey();
  107.                         return;
  108.                     default:
  109.                         Console.Clear();
  110.                         Console.WriteLine("Ошибка");
  111.                         Console.ReadKey();
  112.                         break;
  113.                 }
  114.             } while (true);
  115.         }
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement