Advertisement
_CodeBehind

asdasdasd

Feb 25th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ExtendedShit
  8. {
  9.     public class Program
  10.     {
  11.         public static void Main()
  12.         {
  13.             var list = new List<int>();
  14.  
  15.             while (true)
  16.             {
  17.                 var line = Console.ReadLine();
  18.                 var lastRemoved = 0;
  19.                 string s = line;
  20.                 int result;
  21.  
  22.                 if (int.TryParse(s, out result))
  23.                 {
  24.                     list.Insert(0, result);
  25.                 }
  26.  
  27.                 else if (line == "bang")
  28.                 {
  29.                    
  30.                     var average = list.Average();
  31.  
  32.                     for (int i = 0; i < list.Count; i++)
  33.                     {
  34.                         if (list[i] <= average)
  35.                         {
  36.                             lastRemoved = list[i];
  37.                             list.Remove(list[i]);
  38.                             Console.WriteLine($"shot {lastRemoved}");
  39.  
  40.                             for (int j = 0; j < list.Count; j++)
  41.                             {
  42.                                 list[j]--;
  43.                             }
  44.  
  45.                             break;
  46.                         }
  47.                     }
  48.                 }
  49.                 if (list.Count == 0)
  50.                 {
  51.                     Console.WriteLine($"nobody left to shoot! last one was {lastRemoved}");
  52.                     break;
  53.                 }
  54.                 if (line == "stop")
  55.                 {
  56.                     if (list.Count==0)
  57.                     {
  58.                         Console.WriteLine($"you shot them all. last one standing was {lastRemoved}");
  59.                         break;
  60.                     }
  61.                     Console.WriteLine($"survivors: { string.Join(" ",list)}");
  62.                     break;
  63.                 }
  64.             }
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement