Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- class BitsInverterTwo
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int step = int.Parse(Console.ReadLine());
- int index = 0;
- var binNumber = new StringBuilder();
- for (int i = 0; i < n; i++)
- {
- binNumber.Append(Convert.ToString(int.Parse(Console.ReadLine()), 2).PadLeft(8, '0'));
- for (int j = 0; j < binNumber.Length; j++)
- {
- index++;
- if ((step == 1) || (index % step == 1))
- {
- if (binNumber[j] == '0')
- {
- binNumber[j] = '1';
- }
- else
- {
- binNumber[j] = '0';
- }
- }
- }
- int intResult = Convert.ToInt32(binNumber.ToString(), 2);
- Console.WriteLine(intResult);
- binNumber.Clear();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment