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;
- namespace ConsoleApplication2
- {
- class Program
- {
- //static bool theCenterOfTheCrossroad(int[] row, int[] column, int i, int j)
- //{
- // bool b;
- // if (column.Contains(j))
- // {
- // }
- //}
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int step = int.Parse(Console.ReadLine());
- int counter = 1;
- int inBitCounter = 0;
- int number = 0;
- List<int> output = new List<int>();
- int checker = 1;
- for (int i = 0; i < n; i++)
- {
- int numberForChange = int.Parse(Console.ReadLine());
- while (1 + inBitCounter * step < (8 * checker))
- {
- numberForChange = numberForChange & 0x0000000FF;
- int bitToBeConverted = (1 + inBitCounter * step) - number;
- int mask = 1 << bitToBeConverted;
- int bit = (numberForChange & mask) >> bitToBeConverted;
- if (bit == 1)
- {
- int maskForConversion = ~(1 << bitToBeConverted);
- numberForChange = (numberForChange & maskForConversion);
- //Console.WriteLine(check);
- }
- else
- {
- int maskForConversion = ~(1 << bitToBeConverted);
- numberForChange = (numberForChange ^ maskForConversion);
- }
- inBitCounter++;
- }
- //check = Convert.ToString(numberForChange, 2).PadRight(8, '0');
- //Console.WriteLine(check);
- output.Add(numberForChange);
- counter++;
- checker++;
- number += 8;
- }
- foreach (var item in output)
- {
- Console.WriteLine(item);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment