ralichka

Exam-30.06.2019-02.TaskPlanner

Oct 30th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _02.TasksPlanner
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> hours = Console.ReadLine()
  12.                 .Split()
  13.                 .Select(int.Parse)
  14.                 .ToList();
  15.  
  16.             string[] command = Console.ReadLine().Split();
  17.  
  18.             string word = command[0];
  19.  
  20.             List<int> incompleted = new List<int>();
  21.  
  22.                 int counterCompleted = 0;
  23.                 int counterIncomplete = 0;
  24.                 int counterDropped = 0;
  25.  
  26.             while (word != "End")
  27.             {
  28.                 if (word == "Complete")
  29.                 {
  30.                     int index = int.Parse(command[1]);
  31.  
  32.                     if (index >= 0 && index < hours.Count)
  33.                     {
  34.                         hours[index] = 0;
  35.                     }
  36.                 }
  37.  
  38.                 else if (word == "Change")
  39.                 {
  40.                     int index = int.Parse(command[1]);
  41.                     int time = int.Parse(command[2]);
  42.  
  43.                     if (index >= 0 && index < hours.Count)
  44.                     {
  45.                         hours[index] = time; ;
  46.                     }
  47.                 }
  48.  
  49.                 else if (word == "Drop")
  50.                 {
  51.                     int index = int.Parse(command[1]);
  52.  
  53.                     if (index >= 0 && index < hours.Count)
  54.                     {
  55.                         hours[index] = -1; ;
  56.                     }
  57.                 }
  58.  
  59.  
  60.                 if (word =="Count")
  61.                 {
  62.                     if (command[1] == "Completed")
  63.                     {
  64.                     for (int i = 0; i < hours.Count; i++)
  65.                     {
  66.                         if (hours[i] == 0)
  67.                         {
  68.                             counterCompleted++;
  69.                         }
  70.                     }
  71.  
  72.                     Console.WriteLine(counterCompleted);
  73.  
  74.                     }
  75.  
  76.                     if (command[1] == "Incomplete")
  77.                     {
  78.                     for (int i = 0; i < hours.Count; i++)
  79.                     {
  80.                         if (hours[i] > 0)
  81.                         {
  82.                             counterIncomplete++;
  83.                         }
  84.                     }
  85.                     Console.WriteLine(counterIncomplete);
  86.  
  87.                     }
  88.  
  89.                     if (command[1] == "Dropped")
  90.                     {
  91.                     for (int i = 0; i < hours.Count; i++)
  92.                     {
  93.                         if (hours[i] < 0)
  94.                         {
  95.                         counterDropped++;
  96.                         }
  97.                     }
  98.                     Console.WriteLine(counterDropped);
  99.  
  100.                     }
  101.  
  102.                 }
  103.                    
  104.                
  105.  
  106.                 command = Console.ReadLine().Split();
  107.                 word = command[0];
  108.  
  109.             }
  110.             for (int i = 0; i < hours.Count; i++)
  111.             {
  112.                 if (hours[i] == 0)
  113.                 {
  114.                     hours.Remove(hours[i]);
  115.                 }
  116.                
  117.             }
  118.  
  119.             for (int i = 0; i < hours.Count; i++)
  120.             {
  121.                 if (hours[i] < 0)
  122.                 {
  123.                     hours.Remove(hours[i]);
  124.                 }
  125.             }
  126.  
  127.  
  128.             Console.WriteLine(string.Join(" ",hours));
  129.  
  130.         }
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment