Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- namespace BookWorm
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] stack = Console.ReadLine().Split(",").Select(int.Parse).ToArray();
- int[] queue = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int kill = int.Parse(Console.ReadLine());
- Stack<int> task = new Stack<int>(stack);
- Queue<int> thread = new Queue<int>(queue);
- while (task.Any() && thread.Any())
- {
- if (task.Peek() == kill)
- {
- break;
- }
- if (thread.Peek() >= task.Peek())
- {
- task.Pop();
- thread.Dequeue();
- }
- else
- {
- thread.Dequeue();
- }
- }
- Console.WriteLine($"Thread with value {thread.Peek()} killed task {task.Peek()}");
- Console.WriteLine(string.Join(" ", thread));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement