Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Threading;
- namespace ConsoleApp1
- {
- class Exam
- {
- static void Main(string[] args)
- {
- List<int> tasks = Console.ReadLine().Split().Select(int.Parse).ToList();
- string[] command = Console.ReadLine().Split().ToArray();
- while (command[0] != "End")
- {
- if (command[0] == "Complete")
- {
- Completed(tasks, command);
- }
- if (command[0] == "Change")
- {
- Change(tasks, command);
- }
- if (command[0] == "Drop")
- {
- Drop(tasks, command);
- }
- if (command[1] == "Completed")
- {
- Completed(tasks);
- }
- if (command[1] == "Incompleted")
- {
- Incompleted(tasks);
- }
- if (command[1] == "Dropped")
- {
- Dropped(tasks);
- }
- command = Console.ReadLine().Split().ToArray();
- }
- tasks.RemoveAll(x => x <= 0);
- Console.WriteLine(string.Join(" ", tasks));
- }
- private static void Completed(List<int> tasks, string[] command)
- {
- int index = int.Parse(command[1]);
- if (index >= 0 && index < tasks.Count)
- {
- tasks[index] = 0;
- }
- }
- private static void Change(List<int> tasks, string[] command)
- {
- int index = int.Parse(command[1]);
- int time = int.Parse(command[2]);
- if (index >= 0 && index < tasks.Count && (time >= 1 && time <= 5))
- {
- if (tasks[index] > 0)
- {
- tasks[index] = time;
- }
- }
- }
- private static void Drop(List<int> tasks, string[] command)
- {
- int index = int.Parse(command[1]);
- if (index >= 0 && index < tasks.Count)
- {
- tasks[index] = -1;
- }
- }
- private static void Completed(List<int> tasks)
- {
- int count = 0;
- foreach (var item in tasks)
- {
- if (item == 0)
- {
- count++;
- }
- }
- Console.WriteLine(count);
- }
- private static void Incompleted(List<int> tasks)
- {
- int count = 0;
- foreach (var item in tasks)
- {
- if (item > 0)
- {
- count++;
- }
- }
- Console.WriteLine(count);
- }
- private static void Dropped(List<int> tasks)
- {
- int count = 0;
- foreach (var item in tasks)
- {
- if (item == -1)
- {
- count++;
- }
- }
- Console.WriteLine(count);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement