Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ArcheryT
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = Console.ReadLine().Split('|').Select(int.Parse).ToArray();
- string input;
- int iskrenPoints = 0;
- while ((input = Console.ReadLine()) != "Game over")
- {
- string[] command = input.Split(' ', '@');
- if (command[0] == "Shoot" && command[1] == "Left")
- {
- int index = int.Parse(command[2]);
- int length = int.Parse(command[3]);
- if (index <= array.Length - 1 && index >= 0)
- {
- while (length != 0)
- {
- if (index > 0) //if it's not on the first index
- {
- index--;
- length--;
- }
- else if (index == 0) //if it's on the first index
- {
- index = array.Length - 1;
- length--;
- }
- }
- if (array[index] >= 5) //if there is enough points
- {
- array[index] -= 5;
- iskrenPoints += 5;
- }
- else //if there isn't is enough points
- {
- iskrenPoints += array[index];
- array[index] = 0;
- }
- }
- }
- else if (command[0] == "Shoot" && command[1] == "Right")
- {
- int index = int.Parse(command[2]);
- int length = int.Parse(command[3]);
- // if the index is valid
- if (index >= 0 && index <= array.Length - 1)
- {
- //while we are going to the target index
- while (length != 0)
- {
- if (index < array.Length - 1)// if it's not on the last index
- {
- index++;
- length--;
- }
- else if (index == array.Length - 1) //// if it's on the last index
- {
- index = 0;
- length--;
- }
- }
- if (array[index] >= 5)
- {
- array[index] -= 5;
- iskrenPoints += 5;
- }
- else
- {
- iskrenPoints += array[index];
- array[index] = 0;
- }
- }
- }
- else if (command[0] == "Reverse")
- {
- Array.Reverse(array);
- }
- }
- for (int i = 0; i < array.Length - 1; i++)
- {
- Console.Write(array[i] + " - ");
- }
- Console.WriteLine(array[array.Length - 1]);
- Console.WriteLine($"Iskren finished the archery tournament with {iskrenPoints} points!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement