Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _17_Catch_the_Bits
- {
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int step = int.Parse(Console.ReadLine());
- int number = 0;
- string all = null;
- char[] seq=new char[n*8];
- string bin = null;
- for (int i = 0; i < n; i++)
- {
- number = int.Parse(Console.ReadLine());
- string input = Convert.ToString(number, 2);
- string inputByte = input.PadLeft(8, '0');
- all = all + inputByte;
- }
- for (int t = 0; t < n*8; t++)
- {
- if (1 + t * step > n * 8)
- {
- continue;
- }
- seq[t] = all[1 + t * step];
- }
- for (int l = 0; l < seq.Length; l++)
- {
- if (seq[l]=='\0')
- {
- continue;
- }
- bin = bin + seq[l];
- }
- int ctr =(int)System.Math.Ceiling((decimal)bin.Length/8);
- string middle = bin.PadRight(ctr*8, '0');
- int p = 0;
- while (p < ctr*8)
- {
- string final = middle.Substring(p, 8);
- int end = Convert.ToInt32(final, 2);
- Console.WriteLine(end);
- p = p + 8;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement