Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TextBombardtment
- {
- class TextBombardtment
- {
- static void Main()
- {
- StringBuilder input = new StringBuilder();
- input.Append(Console.ReadLine());
- int lineWidth = int.Parse(Console.ReadLine());
- int[] columnsToDestroy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- for(int i = 0; i < columnsToDestroy.Length; i++)
- {
- while(columnsToDestroy[i] <= input.Length)
- {
- char getCurrentChar = input[columnsToDestroy[i]];
- char nextChar = ' ';
- if( columnsToDestroy[i] + lineWidth <= input.Length)
- {
- nextChar = ( input[columnsToDestroy[i] + lineWidth] );
- }
- if(!char.IsWhiteSpace(nextChar))
- {
- input.Replace(getCurrentChar , ' ' , columnsToDestroy[i] , 1);
- columnsToDestroy[i] = columnsToDestroy[i] + lineWidth;
- }
- else
- {
- input.Replace(getCurrentChar , ' ' , columnsToDestroy[i] , 1);
- columnsToDestroy[i] = columnsToDestroy[i] + lineWidth;
- break;
- }
- }
- }
- Console.WriteLine(input);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement