stefan1919

Text bombardment demo

Aug 4th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.90 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 ConsoleApplication1
  8. {
  9.     class ConsoleApplication1
  10.     {
  11.        
  12.         static void Main(string[] args)
  13.         {
  14.             string p = Console.ReadLine();
  15.             char[] array = p.ToCharArray();
  16.             int numberElements = array.Length;
  17.             int widthTable = int.Parse(Console.ReadLine());
  18.             int height = (numberElements / widthTable) + 1;
  19.             int numberOfTheArray = 0;
  20.             string bombardedPositions = Console.ReadLine();
  21.             string[] numbers = bombardedPositions.Split(' ');
  22.             double positionToBeRemoved = 0;
  23.             int[] bombardInt = bombardedPositions.Split(' ').Select(int.Parse).ToArray();
  24.             bool b = false;
  25.             string m = string.Empty;
  26.            
  27.            
  28.            
  29.             for (int i = 0; i < height; i++)
  30.             {
  31.                 for (int j = 0; j < widthTable; j++)
  32.                 {
  33.                     if (bombardInt.Contains(j))
  34.                     {
  35.                         if (array[numberOfTheArray + 1] == ' ')
  36.                         {
  37.                             if (i == 0)
  38.                             {
  39.                                 numberOfTheArray++;
  40.                                 Console.Write(" ");
  41.                                 m += " ";
  42.                                 continue;
  43.                             }
  44.  
  45.                             else
  46.                             {
  47.                                 bombardInt = bombardInt.Except(new int[] { j }).ToArray();
  48.                                 m += " ";
  49.                             }
  50.                         }
  51.                         else
  52.                         {
  53.                             numberOfTheArray++;
  54.                             Console.Write(" ");
  55.                             m += " ";
  56.                             continue;
  57.                         }
  58.                        
  59.                        
  60.                     }
  61.                     if (i == 0 && j == 0)
  62.                     {
  63.  
  64.                         Console.Write(array[0]);
  65.                         m += array[0];
  66.                     }
  67.  
  68.                     else
  69.                     {
  70.                         numberOfTheArray += 1;
  71.                         if (numberOfTheArray < array.Length)
  72.                         {
  73.                             Console.Write(array[numberOfTheArray]);
  74.                             m += array[numberOfTheArray];
  75.                         }
  76.                         else
  77.                         {
  78.                             Console.Write(" ");
  79.                             m += " ";
  80.                         }
  81.                     }
  82.                 }
  83.                 Console.WriteLine();
  84.             }
  85.             Console.WriteLine(m);
  86.             }
  87.         }
  88.     }
Advertisement
Add Comment
Please, Sign In to add comment