Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int step = int.Parse(Console.ReadLine());
- int[] bitArray = new int[n];
- int result = 0;
- int count = 1;
- int bitCount = 0;
- for (int i = 0; i < n; i++)
- {
- bitArray[i] = int.Parse(Console.ReadLine());
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- if (count == 0)
- {
- int bitOnStep = (bitArray[i] >> 7-j) & 1;
- result = (result << 1) | bitOnStep;
- count = step;
- bitCount++;
- if (bitCount == 8)
- {
- Console.WriteLine(result);
- result = 0;
- bitCount = 0;
- }
- }
- count--;
- }
- }
- if (bitCount > 0)
- {
- result = (result << (8 - bitCount));
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement