Advertisement
Guest User

Untitled

a guest
Jan 30th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace _2.Tasks_Planner
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int[] nums = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
  11. string command = Console.ReadLine();
  12.  
  13. while (command!="End")
  14. {
  15. string[] tokens = command.Split(" ");
  16.  
  17. if (tokens[0]== "Complete")
  18. {
  19. int index = int.Parse(tokens[1]);
  20. if (index>=0 && index<nums.Length)
  21. {
  22. nums[index] = 0;
  23. }
  24. }
  25. else if (tokens[0]== "Change")
  26. {
  27. int index = int.Parse(tokens[1]);
  28. int time = int.Parse(tokens[2]);
  29.  
  30. if (index >= 0 && index < nums.Length)
  31. {
  32. nums[index] = time;
  33. }
  34. }
  35. else if (tokens[0] == "Drop")
  36. {
  37. int index = int.Parse(tokens[1]);
  38.  
  39. if (index >= 0 && index < nums.Length)
  40. {
  41. nums[index] = -1;
  42. }
  43. }
  44. else if (command=="Count Completed")
  45. {
  46. int counter = 0;
  47. foreach (var num in nums)
  48. {
  49. if (num==0)
  50. {
  51. counter++;
  52. }
  53. }
  54. Console.WriteLine(counter);
  55. }
  56. else if (command== "Count Incomplete")
  57. {
  58. int counter = 0;
  59. foreach (var num in nums)
  60. {
  61. if (num > 0)
  62. {
  63. counter++;
  64. }
  65. }
  66. Console.WriteLine(counter);
  67. }
  68. else if (command=="Count Dropped")
  69. {
  70. int counter = 0;
  71. foreach (var num in nums)
  72. {
  73. if (num < 0)
  74. {
  75. counter++;
  76. }
  77. }
  78. Console.WriteLine(counter);
  79. }
  80. command = Console.ReadLine();
  81. }
  82. var incomplete = new List<int>();
  83. foreach (var num in nums)
  84. {
  85. if (num>0)
  86. {
  87. incomplete.Add(num);
  88. }
  89. }
  90. Console.WriteLine(string.Join(" ",incomplete));
  91. }
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement