Advertisement
Guest User

Untitled

a guest
Aug 5th, 2019
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 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. using System.Text.RegularExpressions;
  7. namespace _03.Exact_Sum_of_Real_Numbers
  8. {
  9. class Program
  10. {
  11.  
  12.  
  13.  
  14. static void Main()
  15. {
  16. List<double> numbers = Console.ReadLine()
  17. .Split()
  18. .Select(double.Parse)
  19. .ToList();
  20.  
  21. while (true)
  22. {
  23. string line = Console.ReadLine();
  24.  
  25.  
  26.  
  27. string[] tokens = line.Split();
  28.  
  29. switch (tokens[0])
  30. {
  31. case "Complete":
  32. int indexToComplete = int.Parse(tokens[1]);
  33. int completeIndexCheck = numbers.Count();
  34. if (0 <= indexToComplete && indexToComplete < numbers.Count)
  35. {
  36. numbers.RemoveAt(indexToComplete);
  37. numbers.Insert(indexToComplete, 0);
  38. }
  39. else
  40. {
  41.  
  42.  
  43. }
  44. break;
  45. case "Change":
  46. int changeIndexCheck = numbers.Count();
  47. int indexToChange = int.Parse(tokens[1]);
  48. int timeToChange = int.Parse(tokens[2]);
  49. if (0 <= indexToChange && indexToChange < numbers.Count)
  50. {
  51. numbers.RemoveAt(indexToChange);
  52. numbers.Insert(indexToChange, timeToChange);
  53. }
  54. else
  55. {
  56.  
  57.  
  58. }
  59.  
  60. break;
  61. case "Drop":
  62. int droppedIndexCheck = numbers.Count();
  63. int indexToDrop = int.Parse(tokens[1]);
  64. if (0 <= indexToDrop && indexToDrop < numbers.Count)
  65. {
  66. numbers.RemoveAt(indexToDrop);
  67. numbers.Insert(indexToDrop, -1);
  68. }
  69. else
  70. {
  71.  
  72.  
  73.  
  74. }
  75. break;
  76.  
  77. }
  78. if (tokens[0] == "Count" && tokens[1] == "Completed")
  79. {
  80. var listB = numbers.FindAll(x => x == 0);
  81. int countOfCompleted = listB.Count();
  82. Console.WriteLine(string.Join("", countOfCompleted));
  83. }
  84. else if (tokens[0] == "Count" && tokens[1] == "Incomplete")
  85. {
  86. var listC = numbers.FindAll(x => x > 0);
  87. int countOfIncomplete = listC.Count();
  88. Console.WriteLine(string.Join("", countOfIncomplete));
  89. }
  90. else if (tokens[0] == "Count" && tokens[1] == "Dropped")
  91. {
  92. var listD = numbers.FindAll(x => x == -1);
  93. int countOfDropped = listD.Count();
  94. Console.WriteLine(string.Join("", countOfDropped));
  95. }
  96. else if (tokens[0] == "End")
  97. {
  98. var Incomplete = numbers.FindAll(x => x > 0);
  99. Console.WriteLine(string.Join(" ", Incomplete));
  100. break;
  101. }
  102. }
  103.  
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement