Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.62 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string [] namesArray = new string [0];
  10.             string [] positionsArray = new string [0];
  11.  
  12.             do
  13.             {
  14.                 Console.WriteLine("1. Добавить досье");
  15.                 Console.WriteLine("2. Вывести все досье");
  16.                 Console.WriteLine("3. Удалить досье");
  17.                 Console.WriteLine("4. Выход");
  18.  
  19.                 Console.WriteLine("Введите нужный пункт меню");
  20.                 string userInput = Console.ReadLine();
  21.  
  22.                 switch (userInput)
  23.                 {
  24.                     case "1":
  25.                         Console.WriteLine("Введите Фамилию Имя Отчество\n");
  26.                         string name = Console.ReadLine();
  27.  
  28.                         Console.WriteLine("Введите должность\n");
  29.                         string position = Console.ReadLine();
  30.  
  31.                         AddNewDosje(name, position, ref namesArray, ref positionsArray);
  32.                         Console.Clear();
  33.  
  34.                         break;
  35.  
  36.                     case "2":
  37.                         PrintDosje(namesArray, positionsArray);
  38.                         break;
  39.                 }
  40.  
  41.             } while (true);
  42.  
  43.         }
  44.  
  45.         static void AddNewDosje(string name, string position, ref string[] namesArray, ref string[] positionsArray)
  46.         {
  47.             string[] tempNamesArray = new string[namesArray.Length + 1];
  48.            
  49.  
  50.             for (int i = 0; i < namesArray.Length; i++)
  51.             {
  52.                 tempNamesArray[i] = namesArray[i];
  53.             }
  54.  
  55.             namesArray = tempNamesArray;
  56.             namesArray[namesArray.Length - 1] = name;
  57.  
  58.             string[] tempPositionsArray = new string[positionsArray.Length + 1];
  59.            
  60.  
  61.             for (int i = 0; i < positionsArray.Length; i++)
  62.             {
  63.                 tempPositionsArray[i] = positionsArray[i];
  64.             }
  65.  
  66.             positionsArray = tempPositionsArray;
  67.             positionsArray[positionsArray.Length - 1] = position;
  68.         }
  69.  
  70.         static void PrintDosje(string[] namesArray, string[] positionsArray)
  71.         {
  72.             Console.Clear();
  73.  
  74.             for (int i = 0; i < namesArray.Length; i++)
  75.             {
  76.                
  77.                 Console.WriteLine((i + 1) + ". " + namesArray[i] + " - " + positionsArray[i]);
  78.             }
  79.  
  80.             Console.ReadLine();
  81.             Console.Clear();
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement