Advertisement
Guest User

Untitled

a guest
May 8th, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 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_9
  8. {
  9.     class TerroristsWin_9
  10.     {
  11.         static char[] text;
  12.  
  13.         static void PrintArray()
  14.         {
  15.             foreach (var ch in text)
  16.             {
  17.                 Console.Write(ch+" ");
  18.             }
  19.             Console.WriteLine();
  20.         }
  21.         static void CalcBomb(int start, int end,int bomb)
  22.         {
  23.             int beginning = start - bomb;
  24.             int finall = end + bomb;
  25.             if (bomb == 0)
  26.             {
  27.                 return;
  28.             }
  29.  
  30.             if (beginning < 0)
  31.             {
  32.                 beginning = 0;
  33.             }
  34.             else if (finall>(text.Length-1))
  35.             {
  36.                 finall = text.Length - 1;
  37.             }
  38.                    
  39.             for (int i = beginning; i <= finall; i++)
  40.             {
  41.                 text[i] = '.';
  42.             }          
  43.         }
  44.         static void Main(string[] args)
  45.         {
  46.             text = Console.ReadLine().ToCharArray();
  47.             int bombStart = 0;
  48.             int bombEnd = 0;
  49.            
  50.            
  51.             for (int a = 0; a < text.Length; a++)
  52.             {
  53.                 int sum = 0;
  54.                 int bombCapacity = 0;
  55.                 if (text[a].Equals('|'))
  56.                 {
  57.                     bombStart = a;
  58.                     for (int b = a + 1; b < text.Length; b++)
  59.                     {                      
  60.                         if (text[b].Equals('|'))
  61.                         {
  62.                             bombEnd = b;
  63.                             a = b;
  64.                             bombCapacity = sum % 10;
  65.                             CalcBomb(bombStart, bombEnd, bombCapacity);
  66.                             break;
  67.                         }
  68.                         sum += text[b];
  69.                     }
  70.                 }
  71.             }
  72.             PrintArray();
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement