Advertisement
Tervel

02_MidArray

Feb 16th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02_MidArray
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string[] timeOfEachTaskArray = Console.ReadLine().Split();
  10. int[] timeOfEachTaskArrayIntiger = new int[timeOfEachTaskArray.Length];
  11. string command = "";
  12.  
  13. int taskIntigerCheker = 0;
  14. int taskIntigerTime = 0;
  15. int dropTask = 0;
  16. int countIncomplete = 0;
  17. int completeCounter = 0;
  18.  
  19. for (int i = 0; i < timeOfEachTaskArray.Length; i++)
  20. {
  21. timeOfEachTaskArrayIntiger[i] = int.Parse(timeOfEachTaskArray[i]);
  22. }
  23.  
  24.  
  25. while ((command = Console.ReadLine()) != "End")
  26. {
  27. string[] task = command.Split();
  28.  
  29. for (int i = 0; i < timeOfEachTaskArrayIntiger.Length; i++)
  30. {
  31. if (timeOfEachTaskArrayIntiger[i] < 0)
  32. {
  33. continue;
  34. }
  35. if (task[0] == "Complete")
  36. {
  37. taskIntigerCheker = int.Parse(task[1]);
  38. if (taskIntigerCheker == i)
  39. {
  40. timeOfEachTaskArrayIntiger[i] = 0;
  41. }
  42. }
  43. else if (task[0] == "Change")
  44. {
  45. taskIntigerTime = int.Parse(task[2]);
  46. taskIntigerCheker = int.Parse(task[1]);
  47. if (taskIntigerCheker == i)
  48. {
  49. timeOfEachTaskArrayIntiger[i] = taskIntigerTime;
  50. }
  51. }
  52. else if (task[0] == "Drop" && timeOfEachTaskArrayIntiger[i] > 0)
  53. {
  54. taskIntigerCheker = int.Parse(task[1]);
  55. if (taskIntigerCheker == i)
  56. {
  57. timeOfEachTaskArrayIntiger[i] = -1;
  58. }
  59. }
  60. else if (task[0] == "Count" && task[1] == "Completed")
  61. {
  62. for (int j = 0; j < timeOfEachTaskArrayIntiger.Length; j++)
  63. {
  64. if (timeOfEachTaskArrayIntiger[j] == 0)
  65. {
  66. completeCounter++;
  67. }
  68. }
  69. Console.WriteLine(completeCounter);
  70. break;
  71. }
  72. else if (task[0] == "Count" && task[1] == "Incomplete")
  73. {
  74. for (int j = 0; j < timeOfEachTaskArrayIntiger.Length; j++)
  75. {
  76. if (timeOfEachTaskArrayIntiger[j] > 0)
  77. {
  78. countIncomplete++;
  79. }
  80. }
  81. Console.WriteLine(countIncomplete);
  82. break;
  83. }
  84. else if (task[0] == "Count" && task[1] == "Dropped")
  85. {
  86. for (int j = 0; j < timeOfEachTaskArrayIntiger.Length; j++)
  87. {
  88. if (timeOfEachTaskArrayIntiger[j] < 0)
  89. {
  90. dropTask++;
  91. }
  92. }
  93. Console.WriteLine(dropTask);
  94. break;
  95. }
  96. }
  97. }
  98.  
  99. for (int i = 0; i < timeOfEachTaskArrayIntiger.Length; i++)
  100. {
  101. if (timeOfEachTaskArrayIntiger[i] > 0)
  102. {
  103. Console.Write($"{timeOfEachTaskArrayIntiger[i]} ");
  104. }
  105. else
  106. {
  107. continue;
  108. }
  109. }
  110. }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement