Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Tasks_Planner
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] tasksHours = Console.ReadLine().Split().Select(int.Parse).ToArray();
- string input = Console.ReadLine();
- while (input != "End")
- {
- string[] command = input.Split().ToArray();
- switch (command[0])
- {
- case "Complete":
- int index = int.Parse(command[1]);
- if (index >= 0 || index < tasksHours.Length)
- {
- tasksHours[index] = 0;
- }
- break;
- case "Change":
- index = int.Parse(command[1]);
- if (index >= 0 || index < tasksHours.Length)
- {
- int newTime = int.Parse(command[2]);
- tasksHours[index] = newTime;
- }
- break;
- case "Drop":
- index = int.Parse(command[1]);
- if (index >= 0 || index < tasksHours.Length)
- {
- tasksHours[index] = -1;
- }
- break;
- case "Count":
- string secondCommandCount = command[1];
- if (secondCommandCount == "Completed")
- {
- int countCompleted = 0;
- foreach (var taskHour in tasksHours)
- {
- if (taskHour == 0)
- {
- countCompleted++;
- }
- }
- Console.WriteLine(countCompleted);
- }
- else if (secondCommandCount == "Incomplete")
- {
- int countInCompleted = 0;
- foreach (var taskHour in tasksHours)
- {
- if (taskHour > 0)
- {
- countInCompleted++;
- }
- }
- Console.WriteLine(countInCompleted);
- }
- else if (secondCommandCount == "Dropped")
- {
- int countDropped = 0;
- foreach (var taskHour in tasksHours)
- {
- if (taskHour < 0)
- {
- countDropped++;
- }
- }
- Console.WriteLine(countDropped);
- }
- break;
- }
- input = Console.ReadLine();
- }
- var incomplete = new List<int>();
- foreach (var taskHour in tasksHours)
- {
- if (taskHour > 0)
- {
- incomplete.Add(taskHour);
- }
- }
- Console.WriteLine(string.Join(" ", incomplete));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement