Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _02_SecondExercise
- {
- class LadyBug
- {
- static void Main(string[] args)
- {
- int lenghtOfarray = int.Parse(Console.ReadLine());
- int[] ladyBug = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- int[] arr = new int[lenghtOfarray];
- ///
- for (int i = 0; i < lenghtOfarray; i++)
- {
- if (i < ladyBug.Length)
- { arr[i] = ladyBug[i]; }
- else
- arr[i] = 0;
- }
- //
- while (true)
- {
- string move = Console.ReadLine();
- if (move == "end" || move == "End")
- { break; }
- string[] movearr = (move).Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
- int position = int.Parse(movearr[0]);
- int step = int.Parse(movearr[2]);
- if (movearr[2] == "right")
- {
- if (arr[position] == 0) { break; }
- if (arr[position] != 0)
- {
- for (int i = 0; i < step; i++)
- {
- if (arr[position + i] == 0)
- {
- arr[position + i] = 1;
- break;
- }
- if (arr[position + i] != 0)
- {
- arr[position + i] = 0;
- arr[position + i] = 1;
- }
- }
- }
- }
- if (movearr[2] == "left")
- {
- for (int i = 0; i < step; i++)
- {
- if (arr[position - i] == 0)
- {
- arr[position - i] = 1;
- break;
- }
- if (arr[position - i] != 0)
- {
- arr[position - i] = 0;
- arr[position - i] = 1;
- }
- }
- }
- }
- Console.WriteLine(String.Join(" ", arr));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement