fbinnzhivko

05.00 BitsInverter

Apr 27th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2. class BitsInverter
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         int step = int.Parse(Console.ReadLine());
  8.         int index = 0;
  9.         for (int i = 0; i < n; i++)
  10.         {
  11.             int num = int.Parse(Console.ReadLine());
  12.             for (int bit = 7; bit >= 0; bit--)
  13.             {
  14.                 index++;
  15.                 if ((step == 1) || (index % step == 1))
  16.                 {
  17.                     num = num ^ (1 << bit);
  18.                 }
  19.             }
  20.             Console.WriteLine(num);
  21.         }
  22.     }
  23. }
Add Comment
Please, Sign In to add comment