Advertisement
alidzhikov

TerroristsWin

May 8th, 2015
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. class TerroristsWin
  5. {
  6.     static void Main()
  7.     {
  8.         string inputText = Console.ReadLine();
  9.  
  10.         StringBuilder inputTextAsStringBuilder = new StringBuilder(inputText);
  11.         int startIndex = inputText.IndexOf('|');
  12.         int endIndex = 0;
  13.         int unicodeSum = 0;
  14.         int destroyedArea = 0;
  15.         while (startIndex != -1)
  16.         {
  17.             unicodeSum = 0;
  18.             endIndex = inputText.IndexOf('|', startIndex + 1);
  19.             if (endIndex <= startIndex)
  20.             {
  21.                 break;
  22.             }
  23.             for (int i = startIndex + 1; i <= endIndex - 1; i++)
  24.             {
  25.                 unicodeSum += inputText[i];
  26.                 inputTextAsStringBuilder[i] = '.';
  27.             }
  28.             destroyedArea = unicodeSum % 10;
  29.  
  30.             for (int i = startIndex; i >= startIndex - destroyedArea && i >= 0; i--)
  31.             {
  32.                 inputTextAsStringBuilder[i] = '.';
  33.             }
  34.             for (int i = endIndex; i <= endIndex + destroyedArea && i < inputTextAsStringBuilder.Length; i++)
  35.             {
  36.                 inputTextAsStringBuilder[i] = '.';
  37.             }
  38.  
  39.             startIndex = inputText.IndexOf('|', endIndex + 1);
  40.         }
  41.         Console.WriteLine(inputTextAsStringBuilder);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement