TwinFrame

LINQ_Amnition_ver2

Dec 19th, 2020 (edited)
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Clight_39_LINQ_Amnition
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. Random random = new Random();
  12.  
  13. List<string> fio = new List<string> { "Иванов А.Г.", "Владимиров Б.У.", "Оксанин Г.В." , "Генацвали А.В." , "Маринин С.А.",
  14. "Игорян Х.А.", "Евгенов С.М.", "Мариуполев С.В", "Надеждина Н.Т.", "Русланков В.А.", "Сергеев Н.Н.", "Иринина И.П.",
  15. "Маринок Ж.А.", "Игрил Х.Х.", "Оксигенов П.С.", "Возбудидзе А.Ю.", "Попин М.Ю.", "Сааркян С.И." };
  16.  
  17. List<string> typesOfCrimes = new List<string> { "Антиправительственное", "Административное", "Вандальное", "Пранковое" };
  18.  
  19. while (true)
  20. {
  21. Console.Clear();
  22.  
  23. Dictionary<string, string> prisoners = new Dictionary<string, string>();
  24.  
  25. foreach (var item in fio)
  26. {
  27. prisoners.Add(item, typesOfCrimes[random.Next(0, typesOfCrimes.Count)]);
  28. }
  29.  
  30. Console.WriteLine("Список заключенных до амнистии:");
  31. ShowPrisonerInfo(prisoners);
  32.  
  33. var amnistianPrisoner = from prisoner in prisoners
  34. where prisoner.Value != "Антиправительственное"
  35. select prisoner;
  36.  
  37. Console.WriteLine("\nСписок заключенных после амнистии:");
  38.  
  39. foreach (var prisoner in amnistianPrisoner)
  40. {
  41. Console.WriteLine($"Ф.И.О.: { prisoner.Key}, Нарушение: { prisoner.Value}");
  42. }
  43.  
  44. Console.ReadKey();
  45. }
  46. }
  47.  
  48. static void ShowPrisonerInfo(Dictionary<string, string> prisoners)
  49. {
  50. foreach (var prisoner in prisoners)
  51. {
  52. Console.WriteLine($"Ф.И.О.: {prisoner.Key}, Нарушение: {prisoner.Value}");
  53. }
  54. }
  55. }
  56. }
  57.  
Add Comment
Please, Sign In to add comment