Advertisement
Guest User

Untitled

a guest
Jan 30th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.71 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace Tasks_Planner
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] tasksHours = Console.ReadLine().Split().Select(int.Parse).ToArray();
  11.  
  12.             string input = Console.ReadLine();
  13.  
  14.  
  15.             while (input != "End")
  16.  
  17.             {
  18.                 string[] command = input.Split().ToArray();
  19.  
  20.                 switch (command[0])
  21.  
  22.                 {
  23.                     case "Complete":
  24.  
  25.                         int index = int.Parse(command[1]);
  26.  
  27.                         if (index >= 0 || index < tasksHours.Length)
  28.  
  29.                         {
  30.  
  31.                             tasksHours[index] = 0;
  32.                         }
  33.                         break;
  34.  
  35.                     case "Change":
  36.  
  37.                         index = int.Parse(command[1]);
  38.  
  39.                         if (index >= 0 || index < tasksHours.Length)
  40.  
  41.                         {
  42.  
  43.  
  44.                             int newTime = int.Parse(command[2]);
  45.                             tasksHours[index] = newTime;
  46.                         }
  47.                         break;
  48.  
  49.                     case "Drop":
  50.                         index = int.Parse(command[1]);
  51.  
  52.                         if (index >= 0 || index < tasksHours.Length)
  53.  
  54.                         {
  55.  
  56.                             tasksHours[index] = -1;
  57.                         }
  58.                         break;
  59.  
  60.                     case "Count":
  61.  
  62.                         string secondCommandCount = command[1];
  63.                        
  64.                         if (secondCommandCount == "Completed")
  65.  
  66.                         {
  67.                             int countCompleted = 0;
  68.  
  69.                             foreach (var taskHour in tasksHours)
  70.  
  71.                             {
  72.                                 if (taskHour == 0)
  73.  
  74.                                 {
  75.                                     countCompleted++;
  76.  
  77.                                 }
  78.  
  79.                             }
  80.                             Console.WriteLine(countCompleted);
  81.  
  82.                         }
  83.  
  84.                        
  85.  
  86.                         else if (secondCommandCount == "Incomplete")
  87.  
  88.                         {
  89.                             int countInCompleted = 0;
  90.                             foreach (var taskHour in tasksHours)
  91.  
  92.                             {
  93.                                 if (taskHour > 0)
  94.  
  95.                                 {
  96.                                     countInCompleted++;
  97.  
  98.  
  99.                                 }
  100.  
  101.                             }
  102.  
  103.                             Console.WriteLine(countInCompleted);
  104.                         }
  105.  
  106.                         else if (secondCommandCount == "Dropped")
  107.  
  108.                         {
  109.                             int countDropped = 0;
  110.                             foreach (var taskHour in tasksHours)
  111.  
  112.                             {
  113.                                 if (taskHour < 0)
  114.  
  115.                                 {
  116.                                     countDropped++;
  117.  
  118.                                 }
  119.  
  120.                             }
  121.                             Console.WriteLine(countDropped);
  122.  
  123.  
  124.                         }
  125.                         break;
  126.  
  127.                 }
  128.                 input = Console.ReadLine();
  129.             }
  130.  
  131.             var incomplete = new List<int>();
  132.  
  133.             foreach (var taskHour in tasksHours)
  134.  
  135.             {
  136.                 if (taskHour > 0)
  137.  
  138.                 {
  139.  
  140.                     incomplete.Add(taskHour);
  141.                 }
  142.  
  143.                
  144.             }
  145.             Console.WriteLine(string.Join(" ", incomplete));
  146.         }
  147.     }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement