Guest User

Untitled

a guest
Dec 7th, 2019
234
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Pr1_26102019_DatingApp
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. //////100/100 //////////////////////
  12. Stack<int> males = new Stack<int>(Console.ReadLine().Split().Select(int.Parse));
  13. Queue<int> females = new Queue<int>(Console.ReadLine().Split().Select(int.Parse));
  14. int matching = 0;
  15. while (males.Any() && females.Any())
  16. {
  17.  
  18. int currentMales = males.Peek();
  19. int currentFemales = females.Peek();
  20.  
  21. if (currentFemales <= 0)//proverka za 0 - clear
  22. {
  23. females.Dequeue();
  24. continue;
  25.  
  26. }
  27. if (currentMales <= 0)// proverka za 0 - clear
  28. {
  29. males.Pop();
  30. continue;
  31. }
  32. if (currentMales % 25 == 0)//proverka za "Special case"
  33. {
  34. males.Pop();
  35. males.Pop();
  36. continue;
  37. }
  38. if (currentFemales % 25 == 0)//proverka za "Special case" - ot uslovieto
  39. {
  40. females.Dequeue();
  41. females.Dequeue();
  42. continue;
  43. }
  44.  
  45. if (currentMales == currentFemales)//proverka za el = el
  46. {
  47. matching++;
  48. males.Pop();
  49. females.Dequeue();
  50. }
  51. else//ot uslovieto- "Otherwise you should remove only the female and decrease the value of the male by 2."
  52. {
  53. females.Dequeue();
  54. males.Push(males.Pop() - 2);
  55. }
  56.  
  57. }
  58. /////PRINT LINE 1/////////////////
  59. Console.WriteLine($"Matches: {matching}");
  60. /////line 2//////////////
  61. if (males.Any())
  62. {
  63. Console.WriteLine($"Males left: {string.Join(", ",males)}");
  64. }
  65. else
  66. {
  67. Console.WriteLine("Males left: none");
  68. }
  69. //////// PRINT line 3 /////////////////////
  70. if (females.Any())
  71. {
  72. Console.WriteLine($"Females left: "+string.Join(", ", females));
  73. }
  74. else
  75. {
  76. Console.WriteLine("Females left: none");
  77. }
  78.  
  79.  
  80. }
  81. }
  82. }
RAW Paste Data