Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class TxtBomb
- {
- static void Main()
- {
- string text = Console.ReadLine();
- int lineWidth = int.Parse(Console.ReadLine());
- string[] bombsInput = Console.ReadLine().Split();
- double rows = text.Length / (double)lineWidth;
- rows = Math.Ceiling(rows);
- char[,] matrix = new char[(int)rows, lineWidth];
- //fill the matrix
- int counter = 0;
- for (int row = 0; row < (int)rows; row++)
- {
- for (int col = 0; col < lineWidth; col++)
- {
- matrix[row, col] = text[counter];
- counter++;
- if (counter == text.Length)
- {
- break;
- }
- }
- }
- int[] bombs = new int[bombsInput.Length];
- for (int i = 0; i < bombsInput.Length; i++)
- {
- bombs[i] = int.Parse(bombsInput[i]);
- }
- //bombard
- for (int i = 0; i < bombs.Length; i++)
- {
- int bomb = bombs[i];
- bool damageDone = false; //if the first row is empty, the bomb should continue
- for (int j = 0; j < (int)rows; j++)
- {
- if (matrix[j, bomb] == ' ' && damageDone)
- {
- break;
- }
- else if (matrix[j, bomb] != ' ')
- {
- matrix[j, bomb] = ' ';
- damageDone = true;
- }
- }
- }
- // print
- for (int i = 0; i < (int)rows; i++)
- {
- for (int j = 0; j < lineWidth; j++)
- {
- if (matrix[i, j] == '\0' )
- {
- continue;
- }
- Console.Write(matrix[i, j]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement