Advertisement
Aborigenius

CamelBack-RemoveAt

Jun 29th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 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 CamelsBack
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> start = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.             int camelBack = int.Parse(Console.ReadLine());
  15.             int rounds = 0;
  16.             int lenght = start.Count;
  17.             for (int i = 0; i <= camelBack; i++)
  18.             {
  19.                 if (lenght != camelBack)
  20.                 {
  21.                     start.RemoveAt(start.Count - 1);
  22.                     start.RemoveAt(0);
  23.                     rounds++;
  24.                     lenght -= 2;
  25.                 }
  26.  
  27.             }
  28.             List<string> result = new List<string>();
  29.             foreach (var item in start)
  30.             {
  31.                 result.Add(item.ToString());
  32.             }
  33.  
  34.             if (rounds != 0)
  35.             {
  36.                 Console.WriteLine($"{rounds} rounds");
  37.                 Console.Write("remaining: ");
  38.                
  39.             }
  40.             else
  41.             {
  42.                 Console.Write("already stable: ");
  43.             }
  44.             Console.WriteLine(string.Join(" ", result));
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement