Advertisement
Guest User

Untitled

a guest
Jul 14th, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TerroristsWin
  8. {
  9.     class TerroristsWin
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             char[] input = Console.ReadLine().ToCharArray();
  14.            
  15.             int impact1 = 0;
  16.             int impact2 = 0;
  17.             for (int i = 0; i < input.Length; i++)
  18.             {
  19.                 if (input[i].ToString() == "|")
  20.                 {
  21.                     impact1 = i;
  22.                     i++;
  23.                     StringBuilder sb = new StringBuilder();
  24.                     while (input[i].ToString() != "|")
  25.                     {
  26.                         sb.Append(input[i]);
  27.                         i++;
  28.                     }
  29.                     impact2 = i;
  30.                     Explosion(input, sb, impact1, impact2);
  31.                 }
  32.             }
  33.             Console.WriteLine(String.Join("", input));
  34.         }
  35.  
  36.         private static void Explosion(char[] input, StringBuilder sb, int impact1, int impact2)
  37.         {
  38.             string bomb = sb.ToString();
  39.             int sum = 0;
  40.             for (int j = 0; j < bomb.Length; j++)
  41.             {
  42.                 sum += (char)bomb[j];
  43.             }
  44.             int radius = sum % 10;
  45.             for (int h = (impact1 - radius < 0 ? 0 : impact1 - radius);
  46.                 h <= (impact2 + radius > input.Length - 1 ? input.Length - 1 : impact2 + radius); h++)
  47.             {
  48.                 input[h] = '.';
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement