Advertisement
Guest User

Untitled

a guest
May 30th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _09_Terrorists_Win
  5. {
  6.     internal class Program
  7.     {
  8.         private static void Main()
  9.         {
  10.             string input = Console.ReadLine();
  11.             char[] inputArray = input.ToCharArray();
  12.             for (int i = 0; i < input.Length; i++)
  13.             {
  14.                 int iStart = i;
  15.                 string bomb = "";
  16.                 if (input[i] == '|')
  17.                 {
  18.                     while (input[i + 1] != '|')
  19.                     {
  20.                         bomb += input[i + 1];
  21.                         i++;
  22.                     }
  23.                     i += bomb.Length + 1;
  24.                     int explodeRadius = GetAsciiValue(bomb);
  25.                     for (int j = iStart-explodeRadius; j <= iStart+bomb.Length+1+explodeRadius; j++)
  26.                     {
  27.                         inputArray[j] = '.';
  28.                     }
  29.                 }
  30.             }
  31.             foreach (var a in inputArray)
  32.             {
  33.                 Console.Write(a);
  34.             }
  35.         }
  36.  
  37.         private static int GetAsciiValue(string input)
  38.         {
  39.             int explodeRadius = 0;
  40.             for (int i = 0; i < input.Length; i++)
  41.             {
  42.                 explodeRadius += (int) input[i];
  43.             }
  44.  
  45.             string tmpRadius = explodeRadius.ToString();
  46.             explodeRadius = int.Parse(tmpRadius.Last().ToString());
  47.             return explodeRadius;
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement