Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- namespace fundamental14
- {
- class MainClass
- {
- public static void Main()
- {
- List<string> weapon = Console.ReadLine().Split("|").ToList();
- string input = string.Empty;
- while((input = Console.ReadLine()) != "Done")
- {
- string[] array = input.Split().ToArray();
- string command = array[0];
- string position = array[1];
- if(command == "Move")
- {
- int index = int.Parse(array[2]);
- if (index >= 0 && index < weapon.Count)
- {
- if (position == "Left")
- {
- if (index > 0 && index < weapon.Count)
- {
- string current = weapon[index - 1];
- weapon.RemoveAt(index - 1);
- weapon.Insert(index, current);
- }
- }
- else
- {
- if (index >= 0 && index < weapon.Count - 1)
- {
- string newCurrent = weapon[index];
- weapon.RemoveAt(index);
- weapon.Insert(index + 1, newCurrent);
- }
- }
- }
- }
- else
- {
- if (position == "Odd")
- {
- for (int i = 0; i < weapon.Count; i++)
- {
- if (i % 2 != 0)
- {
- Console.Write($"{weapon[i]} ");
- }
- }
- Console.WriteLine(" ");
- }
- else
- {
- for (int i = 0; i < weapon.Count; i++)
- {
- if (i % 2 == 0)
- {
- Console.Write($"{weapon[i]} ");
- }
- }
- Console.WriteLine(" ");
- }
- }
- }
- StringBuilder sb = new StringBuilder();
- foreach (var kvp in weapon)
- {
- sb.Append(kvp);
- }
- Console.WriteLine($"You crafted {sb}!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement