Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace TasksPlanner
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] tasks = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int completeCounter = 0;
- while (true)
- {
- string[] line = Console.ReadLine()
- .Split(" ",StringSplitOptions.RemoveEmptyEntries)
- .ToArray();
- if (line.Length == 1)
- {
- if (line[0] == "End")
- { break; }
- }
- else if (line.Length == 2)
- {
- if (line[0] == "Complete")
- {
- int index = 0;
- index = int.Parse(line[1]);
- if (index > (tasks.Length - 1))
- { continue; }
- tasks[index] = 0;
- completeCounter++;
- }
- else if (line[0] == "Drop")
- {
- int index = 0;
- index = int.Parse(line[1]);
- if (index > (tasks.Length - 1))
- { continue; }
- tasks[index] = -1;
- }
- else if (line[0] == "Count" && line[1] == "Completed")
- {
- int complete = 0;
- for (int i = 0; i < tasks.Length; i++)
- {
- if (tasks[i] == 0)
- { complete++; }
- }
- Console.WriteLine(complete); }
- else if (line[0] == "Count" && line[1] == "Incompleted")
- { Console.WriteLine(CountIncompleate(tasks)); }
- else if (line[0] == "Count" && line[1] == "Dropped")
- { int dropCounter = 0;
- for (int i = 0; i < tasks.Length; i++)
- {if (tasks[i] < 0)
- { dropCounter++; }
- }
- Console.WriteLine(dropCounter); }
- }
- else if (line.Length == 3)
- {
- int index = 0;
- index = int.Parse(line[1]);
- if (index > (tasks.Length - 1))
- { continue; }
- Change(tasks, line, index);
- }
- }
- Console.WriteLine(String.Join(" ", (Incomplete(tasks))));
- }
- static int[] Incomplete(int[] tasks)
- {
- int counter = 0;
- for (int i = 0; i <= (tasks.Length - 1); i++)
- {
- if (tasks[i] > 0)
- {
- counter++;
- }
- }
- int[] print = new int[counter];
- int fillAray = 0;
- for (int i = 0; i <= (tasks.Length - 1); i++)
- {
- if (tasks[i] > 0)
- {
- print[fillAray] = tasks[i];
- fillAray++;
- }
- }
- return print;
- }
- static int CountIncompleate(int[] tasks)
- {
- int countI = 0;
- for (int i = 0; i < tasks.Length; i++)
- {
- if (tasks[i] < 0)
- { countI++; }
- }
- return countI;
- }
- static void Change(int[] tasks, string[] line, int index)
- {
- int newTime = 0;
- newTime = int.Parse(line[2]);
- tasks[index] = newTime;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement