Advertisement
DragomiraV

LeftIndexRight

Jan 22nd, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp17
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int[] targets = Console.ReadLine().Split('|').Select(int.Parse).ToArray();
  12.             string input = Console.ReadLine();
  13.             int points = 0;
  14.  
  15.             while (input != "Game over")
  16.             {
  17.                 string[] spllited = input.Split(" ");
  18.                 if (spllited[0] == "Reverse")
  19.                 {
  20.                     targets = targets.Reverse().ToArray();/// Така се Reverse при масивите
  21.                 }
  22.  
  23.                 if (spllited[0] == "Shoot")
  24.                 {
  25.                     string[] shooting = spllited[1].Split('@');
  26.                     if (shooting[0] == "Left") //// mestene na dqsno
  27.                     {
  28.                         int index = int.Parse(shooting[1]);
  29.                         int count = int.Parse(shooting[2]); /// тука ни дава колко пъти ще въртим
  30.                         if (index >= 0 && index < targets.Length)
  31.                         {
  32.                             for (int i = 0; i < count; i++)
  33.                             {
  34.                                 index--;
  35.                                 if (index == -1)
  36.                                 {
  37.                                     index = targets.Length - 1;
  38.                                 }
  39.                             }
  40.                             if (targets[index] >= 5)
  41.                             {
  42.                                 targets[index] -= 5;
  43.                                 points += 5;
  44.                             }
  45.                             else if (targets[index] > 0)
  46.                             {
  47.                                 points += targets[index];
  48.                                 targets[index] = 0;
  49.                             }
  50.  
  51.                         }
  52.                     }
  53.                     if (shooting[0] == "Right") /// mestene na dqsno
  54.                     {
  55.                         int index = int.Parse(shooting[1]);
  56.                         int count = int.Parse(shooting[2]);
  57.                         if (index >= 0 && index < targets.Length)
  58.                         {
  59.                             for (int i = 0; i < count; i++)
  60.                             {
  61.                                 index++;
  62.                                 if (index ==targets.Length)
  63.                                 {
  64.                                     index = 0;
  65.                                 }
  66.                             }
  67.                             if (targets[index] >= 5)
  68.                             {
  69.                                 targets[index] -= 5;
  70.                                 points += 5;
  71.                             }
  72.                             else if (targets[index] > 0)
  73.                             {
  74.                                 points += targets[index];
  75.                                 targets[index] = 0;
  76.                             }
  77.  
  78.                         }
  79.                     }
  80.                    
  81.                 }
  82.                 input = Console.ReadLine();
  83.             }
  84.             Console.WriteLine(string.Join(" - ",targets));
  85.             Console.WriteLine($"Iskren finished the archery tournament with {points} points!");
  86.            
  87.  
  88.  
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement