Advertisement
GogoK

TextBombardment

Mar 11th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class TextBombardment
  5. {
  6.     static void Main()
  7.     {
  8.         string input = "Well this problem is gonna be a ride.";
  9.         //string input = Console.ReadLine();
  10.         int width = int.Parse(Console.ReadLine());
  11.         string bombList = Console.ReadLine();
  12.  
  13.         int hight = (int)Math.Ceiling(input.Length / 10.0);
  14.         char[,] arr = new char[hight, width];
  15.  
  16.         int[] bombColums = Array.ConvertAll(bombList.Split(' '), int.Parse);
  17.  
  18.         int count = 0;
  19.         for (int row = 0; row < arr.GetLength(0); row++)
  20.         {
  21.             for (int col = 0; col < arr.GetLength(1); col++)
  22.             {
  23.                 if (count < input.Length)
  24.                 {
  25.                     arr[row, col] = input[count];
  26.                     count++;
  27.                 }
  28.             }
  29.         }
  30.  
  31.         for (int col = 0; col < arr.GetLength(1); col++)
  32.         {
  33.             bool bomb = false;
  34.             char space = ' ';
  35.             int row = 0;
  36.            
  37.             for (int i = 0; i < bombColums.Length; i++)
  38.             {
  39.                 if (bombColums[i] == col)
  40.                 {
  41.                     while (row < arr.GetLength(0))
  42.                     {
  43.                         if (arr[row, col] != space)
  44.                         {
  45.                             arr[row, col] = space;
  46.                             bomb = true;
  47.                         }
  48.                         else if (bomb == true && arr[row, col] == space)
  49.                         {
  50.                             break;
  51.                         }
  52.                         row++;                            
  53.                     }
  54.                     row = 0;
  55.                 }
  56.             }
  57.         }
  58.  
  59.         string result = "";
  60.         for (int row = 0; row < arr.GetLength(0); row++)
  61.         {
  62.             for (int col = 0; col < arr.GetLength(1); col++)
  63.             {
  64.                 result = result + Convert.ToString(arr[row, col]);
  65.             }
  66.         }
  67.         result = result.TrimEnd();
  68.         Console.WriteLine(result);
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement