Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Shoot_list_elements
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> list = new List<int>();
- bool stop = false;
- int lastOne = 0;
- while (!stop)
- {
- string command = Console.ReadLine();
- if (command == "stop")
- {
- if (list.Count > 0)
- {
- Console.WriteLine("survivors: " + string.Join(" ", list));
- }
- else if (list.Count == 0)
- {
- Console.WriteLine($"you shot them all. last one was {lastOne}");
- }
- stop = true;
- }
- else if (command == "bang")
- {
- if (list.Count == 0)
- {
- Console.WriteLine($"nobody left to shoot! last one was {lastOne}");
- stop = true;
- }
- else
- {
- for (int i = 0; i < list.Count; i++)
- {
- if (list[i] <= list.Average())
- {
- Console.WriteLine($"shot {list[i]}");
- lastOne = list[i];
- list.Remove(list[i]);
- list = list.Select(e => e - 1).ToList();
- break;
- }
- }
- }
- //Console.WriteLine(string.Join(" ", list));
- }
- else
- {
- int elementToInsert = int.Parse(command);
- list.Insert(0, elementToInsert);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement