Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace TasksPlanner
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> tasks = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToList();
- int completedCount = 0;
- int droppedCount = 0;
- for (int i = 0; i < tasks.Count; i++)
- {
- if (tasks[i] < 0)
- {
- droppedCount++;
- }
- else if (tasks[i] == 0)
- {
- completedCount++;
- }
- }
- string command = Console.ReadLine();
- while (command != "End")
- {
- string[] currentCommand = command.Split().ToArray();
- if (currentCommand[0] == "Complete")
- {
- if (int.Parse(currentCommand[1]) >= 0 && int.Parse(currentCommand[1]) < tasks.Count)
- {
- tasks[int.Parse(currentCommand[1])] = 0;
- completedCount++;
- }
- }
- else if (currentCommand[0] == "Change")
- {
- if (int.Parse(currentCommand[1]) >= 0 && int.Parse(currentCommand[1]) < tasks.Count)
- {
- tasks[int.Parse(currentCommand[1])] = int.Parse(currentCommand[2]);
- }
- }
- else if (currentCommand[0] == "Drop")
- {
- if (int.Parse(currentCommand[1]) >= 0 && int.Parse(currentCommand[1]) < tasks.Count)
- {
- tasks[int.Parse(currentCommand[1])] = -1;
- droppedCount++;
- }
- }
- else if (currentCommand[0] == "Count" && currentCommand[1] == "Completed")
- {
- Console.WriteLine(completedCount);
- }
- else if (currentCommand[0] == "Count" && currentCommand[1] == "Incomplete")
- {
- Console.WriteLine(tasks.Count);
- }
- else if (currentCommand[0] == "Count" && currentCommand[1] == "Dropped")
- {
- Console.WriteLine(droppedCount);
- }
- command = Console.ReadLine();
- }
- for (int i = 0; i < tasks.Count; i++)
- {
- if (tasks[i] <= 0)
- {
- tasks.Remove(tasks[i]);
- i -= 1;
- }
- }
- Console.WriteLine(String.Join(" ", tasks));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement