stefan1919

started project

Aug 14th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9.     class Program
  10.     {
  11.         //static bool theCenterOfTheCrossroad(int[] row, int[] column, int i, int j)
  12.         //{
  13.         //    bool b;
  14.         //    if (column.Contains(j))
  15.         //    {
  16.                
  17.         //    }
  18.         //}
  19.         static void Main(string[] args)
  20.         {
  21.             int n = int.Parse(Console.ReadLine());
  22.             int step = int.Parse(Console.ReadLine());
  23.             int counter = 1;
  24.             int inBitCounter = 0;
  25.             int number = 0;
  26.             List<int> output = new List<int>();
  27.             int checker = 1;
  28.             for (int i = 0; i < n; i++)
  29.             {
  30.                 int numberForChange = int.Parse(Console.ReadLine());
  31.                 while (1 + inBitCounter * step < (8 * checker))
  32.                 {
  33.                     numberForChange = numberForChange & 0x0000000FF;
  34.                     int bitToBeConverted = (1 + inBitCounter * step) - number;
  35.                     int mask = 1 << bitToBeConverted;
  36.                     int bit = (numberForChange & mask) >> bitToBeConverted;
  37.                     if (bit == 1)
  38.                     {
  39.                         int maskForConversion = ~(1 << bitToBeConverted);
  40.                         numberForChange = (numberForChange & maskForConversion);
  41.                         //Console.WriteLine(check);
  42.  
  43.                     }
  44.                     else
  45.                     {
  46.                         int maskForConversion = ~(1 << bitToBeConverted);
  47.                         numberForChange = (numberForChange ^ maskForConversion);
  48.  
  49.                     }
  50.                     inBitCounter++;
  51.                 }
  52.  
  53.                 //check = Convert.ToString(numberForChange, 2).PadRight(8, '0');
  54.                 //Console.WriteLine(check);
  55.  
  56.                 output.Add(numberForChange);
  57.                 counter++;
  58.                 checker++;
  59.                 number += 8;
  60.                
  61.             }
  62.             foreach (var item in output)
  63.             {
  64.                 Console.WriteLine(item);
  65.             }
  66.  
  67.  
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment