Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _09.TerroristsWin
- {
- using System;
- class TerroristsWin
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- char[] result = text.ToCharArray();
- int bombStart = text.IndexOf('|');
- while (bombStart > -1)
- {
- int bombEnd = text.IndexOf('|', bombStart + 1);
- int bombSum = 0;
- for (int i = bombStart + 1; i < bombEnd; i++)
- {
- bombSum += (int)text[i];
- result[i] = '.';
- }
- int bombPower = bombSum % 10;
- ReplaceDestroyedCharacters(result, bombStart, bombEnd, bombPower);
- bombStart = text.IndexOf('|', bombEnd + 1);
- }
- Console.WriteLine(string.Join(string.Empty, result));
- }
- private static void ReplaceDestroyedCharacters(char[] output, int start, int end, int power)
- {
- for (int i = start; i >= start - power && i >= 0; i--)
- {
- output[i] = '.';
- }
- for (int j = end; j <= end + power && j < output.Length; j++)
- {
- output[j] = '.';
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement