Advertisement
AnastasiyaG

Untitled

Feb 10th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace TasksPlanner
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int[] tasks = Console.ReadLine()
  11. .Split(" ", StringSplitOptions.RemoveEmptyEntries)
  12. .Select(int.Parse)
  13. .ToArray();
  14.  
  15. int completeCounter = 0;
  16.  
  17.  
  18. while (true)
  19. {
  20. string[] line = Console.ReadLine()
  21. .Split(" ",StringSplitOptions.RemoveEmptyEntries)
  22. .ToArray();
  23.  
  24. if (line.Length == 1)
  25. {
  26. if (line[0] == "End")
  27. { break; }
  28. }
  29. else if (line.Length == 2)
  30. {
  31. if (line[0] == "Complete")
  32. {
  33. int index = 0;
  34. index = int.Parse(line[1]);
  35. if (index > (tasks.Length - 1))
  36. { continue; }
  37.  
  38. tasks[index] = 0;
  39.  
  40. completeCounter++;
  41. }
  42.  
  43. else if (line[0] == "Drop")
  44. {
  45. int index = 0;
  46. index = int.Parse(line[1]);
  47. if (index > (tasks.Length - 1))
  48. { continue; }
  49.  
  50. tasks[index] = -1;
  51. }
  52. else if (line[0] == "Count" && line[1] == "Completed")
  53. {
  54. int complete = 0;
  55. for (int i = 0; i < tasks.Length; i++)
  56. {
  57. if (tasks[i] == 0)
  58. { complete++; }
  59.  
  60. }
  61.  
  62.  
  63. Console.WriteLine(complete); }
  64. else if (line[0] == "Count" && line[1] == "Incompleted")
  65. { Console.WriteLine(CountIncompleate(tasks)); }
  66. else if (line[0] == "Count" && line[1] == "Dropped")
  67. { int dropCounter = 0;
  68. for (int i = 0; i < tasks.Length; i++)
  69. {if (tasks[i] < 0)
  70. { dropCounter++; }
  71.  
  72. }
  73. Console.WriteLine(dropCounter); }
  74. }
  75. else if (line.Length == 3)
  76. {
  77. int index = 0;
  78. index = int.Parse(line[1]);
  79. if (index > (tasks.Length - 1))
  80. { continue; }
  81. Change(tasks, line, index);
  82. }
  83.  
  84. }
  85.  
  86. Console.WriteLine(String.Join(" ", (Incomplete(tasks))));
  87. }
  88.  
  89.  
  90.  
  91. static int[] Incomplete(int[] tasks)
  92. {
  93. int counter = 0;
  94.  
  95.  
  96. for (int i = 0; i <= (tasks.Length - 1); i++)
  97. {
  98. if (tasks[i] > 0)
  99. {
  100.  
  101. counter++;
  102. }
  103. }
  104. int[] print = new int[counter];
  105. int fillAray = 0;
  106. for (int i = 0; i <= (tasks.Length - 1); i++)
  107. {
  108. if (tasks[i] > 0)
  109. {
  110. print[fillAray] = tasks[i];
  111. fillAray++;
  112. }
  113. }
  114. return print;
  115. }
  116.  
  117. static int CountIncompleate(int[] tasks)
  118. {
  119. int countI = 0;
  120. for (int i = 0; i < tasks.Length; i++)
  121. {
  122. if (tasks[i] < 0)
  123. { countI++; }
  124.  
  125. }
  126. return countI;
  127. }
  128.  
  129.  
  130. static void Change(int[] tasks, string[] line, int index)
  131. {
  132. int newTime = 0;
  133. newTime = int.Parse(line[2]);
  134.  
  135. tasks[index] = newTime;
  136.  
  137. }
  138.  
  139.  
  140. }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement