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;
- class Program
- {
- static List<string> splitEvery8Bits(string bitwize)
- {
- var list = new List<string>();
- int interval = 8;
- int howManyTimes = bitwize.Length / interval;
- int start = 0;
- for (int i = 0; i < howManyTimes; i++)
- {
- list.Add(bitwize.Substring(start, interval));
- start += interval;
- }
- return list;
- }
- static void Main(string[] args)
- {
- byte n = byte.Parse(Console.ReadLine());
- byte step = byte.Parse(Console.ReadLine());
- StringBuilder sbTheGreat = new StringBuilder(n * 8);
- for (int i = 0; i < n; i++)
- {
- byte numberTOInsert = byte.Parse(Console.ReadLine());
- string representBits = Convert.ToString(numberTOInsert, 2).PadLeft(8, '0');
- sbTheGreat.Append(representBits);
- }
- string temp = sbTheGreat.ToString();
- char[] ableTOChange = temp.ToCharArray();
- int position = 0;
- while (position < ableTOChange.Length)
- {
- if (ableTOChange[position] == '1')
- {
- ableTOChange[position] = '0';
- }
- else if (ableTOChange[position] == '0')
- {
- ableTOChange[position] = '1';
- }
- position += step;
- }
- temp = new string(ableTOChange);
- var ourList = splitEvery8Bits(temp);
- foreach (var item in ourList)
- {
- byte turnAround = Convert.ToByte(item, 2);
- Console.WriteLine(turnAround);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement