Advertisement
TargeTPoweR

Dossier

Mar 30th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 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 Tasks
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Здравствуйте, что вы хотите сделать?");
  14. string[] name = { "Иванов", "Петров", "Сидоров" };
  15. string[] position = { "Менеджер", "Завхоз", "Большая насяльника" };
  16. Console.WriteLine("1 - добавить досье.");
  17. Console.WriteLine("2 - вывести все досье.");
  18. Console.WriteLine("3 - удалить досье.");
  19. Console.WriteLine("4 - найти работника по фамилии.");
  20. Console.WriteLine("5 - выход.");
  21. while (true)
  22. {
  23. int userInput = Convert.ToInt32(Console.ReadLine());
  24.  
  25. if (userInput == 1)
  26. {
  27. Console.WriteLine("Введите фамилию: ");
  28. Array.Resize(ref name, name.Length + 1);
  29. string newName = Console.ReadLine();
  30. name[name.Length - 1] = newName;
  31. Console.WriteLine("Введите должность: ");
  32. Array.Resize(ref position, position.Length + 1);
  33. string newPosition = Console.ReadLine();
  34. position[position.Length - 1] = newPosition;
  35. }
  36. else if (userInput == 2)
  37. {
  38. for (int i = 0; i < name.Length; i++)
  39. {
  40. Console.Write(i + 1 + " ");
  41. Console.Write(name[i] + "-");
  42. Console.Write(position[i] + ". ");
  43. }
  44. Console.WriteLine("");
  45. }
  46. else if (userInput == 3)
  47. {
  48. Console.WriteLine("Введите порядковый номер удаляемого досье.");
  49. int deleteDossier = Convert.ToInt32(Console.ReadLine());
  50. string[] newName = new string[name.Length - 1];
  51. for (int i = 0; i < name.Length; i++)
  52. {
  53. if (i < (deleteDossier - 1))
  54. {
  55. newName[i] = name[i];
  56. }
  57. else if (i > (deleteDossier - 1))
  58. {
  59. newName[i - 1] = name[i];
  60. }
  61. }
  62. name = newName;
  63.  
  64. string[] newPosition = new string[position.Length - 1];
  65. for (int j = 0; j < position.Length; j++)
  66. {
  67. if (j < (deleteDossier))
  68. {
  69. newPosition[j] = position[j];
  70. }
  71. else if (j > (deleteDossier - 1))
  72. {
  73. newPosition[j - 1] = position[j];
  74. }
  75. }
  76. position = newPosition;
  77. }
  78. else if (userInput == 4)
  79. {
  80. Console.WriteLine("Введите фамилию");
  81. string secondName = Console.ReadLine();
  82. for (int i = 0; i < name.Length; i++)
  83. {
  84. if (secondName.ToLower() == name[i].ToLower())
  85. {
  86. Console.WriteLine(i + 1 + position[i]);
  87. break;
  88. }
  89. }
  90. Console.WriteLine("Такого работника нет!!!");
  91. }
  92. else if (userInput == 5)
  93. {
  94. break;
  95. }
  96. }
  97. }
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement