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;
- class BitKiller
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int step = int.Parse(Console.ReadLine());
- int[] bytes = new int[n];
- string bits = "";
- for (int i = 0; i < n; i++)
- {
- bytes[i] = int.Parse(Console.ReadLine());
- string alabala = Convert.ToString(bytes[i], 2).PadLeft(8, '0');
- bits += alabala;
- }
- char[] arrayOfBits = bits.ToCharArray();
- int killPosition = 1;
- int indexer = 1;
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < arrayOfBits.Length; i++)
- {
- if (i != killPosition)
- {
- result.Append(arrayOfBits[i]);
- }
- else
- {
- killPosition = (1+indexer * step);
- indexer++;
- }
- }
- int pad=0;
- if((result.Length % 8)==0)
- {
- pad=(result.Length)/8;
- }
- else if(((result.Length) % 8)!=0)
- {
- pad = (result.Length / 8)+1;
- }
- string endResult = result.ToString().PadRight((pad * 8), '0');
- string[] endNumbers = new string[endResult.Length / 8];
- int index = 0;
- for (int i = 0; i < endNumbers.Length; i++)
- {
- endNumbers[i] = endResult.Substring(index, 8);
- index += 8;
- }
- for (int i = 0; i < endNumbers.Length; i++)
- {
- Console.WriteLine(Convert.ToInt32(endNumbers[i], 2));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment