Advertisement
levamurashev2002

Untitled

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