Advertisement
Guest User

Untitled

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