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 BitKiller
- {
- class Program
- {
- static void Main(string[] args)
- {
- int size = int.Parse(Console.ReadLine());
- int step = int.Parse(Console.ReadLine());
- int[] bytes = new int[size];
- int[] outputArray = new int[0];
- int counter = 0;
- int outputBits = 7;
- int outputBytes = 0;
- int bitValue = 0;
- for (int row = 0; row < bytes.Length; row++)
- {
- bytes[row] = int.Parse(Console.ReadLine());
- for (int col = 7; col >= 0; col--)
- {
- bitValue = bytes[row] >> col & 1;
- if ((counter % step == 1) || (counter != 0 && step == 1))
- {
- counter++;
- continue;
- }
- else if (outputBits > 0)
- {
- if (outputBits == 7)
- {
- Array.Resize(ref outputArray, outputArray.Length + 1);
- }
- outputArray[outputBytes] |= bitValue << outputBits;
- outputBits--;
- }
- else
- {
- outputArray[outputBytes] |= bitValue << outputBits;
- outputBytes++;
- outputBits = 7;
- }
- counter++;
- }
- }
- for (int i = 0; i < outputArray.Length; i++)
- {
- Console.WriteLine("{0}", outputArray[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement