Advertisement
Guest User

NeuronMapping

a guest
Dec 3rd, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. class NeuronMapping
  4. {
  5.     static void Main()
  6.     {
  7.         while (true)
  8.         {
  9.             string inputString = Console.ReadLine();
  10.             if (inputString == "-1")
  11.             {
  12.                 break;
  13.             }
  14.  
  15.             uint bit = (uint)1;
  16.             uint input = uint.Parse(inputString);
  17.             uint output = input;
  18.             int count = 0;
  19.  
  20.             while (true)
  21.             {
  22.                 if (count == 32)
  23.                 {
  24.                     break;
  25.                 }
  26.                 if (((bit << count) & output) == (bit << count))
  27.                 {
  28.                     break;
  29.                 }
  30.                 else
  31.                 {
  32.                     output = (bit << count) | output;
  33.                 }
  34.  
  35.                 count++;
  36.             }
  37.  
  38.             count = 31;
  39.             while (true)
  40.             {
  41.                 if (count == 0)
  42.                 {
  43.                     break;
  44.                 }
  45.                 if (((bit << count) & output) == (bit << count))
  46.                 {
  47.                     break;
  48.                 }
  49.                 else
  50.                 {
  51.                     output = (bit << count) | output;
  52.                 }
  53.  
  54.                 count--;
  55.             }
  56.             Console.WriteLine(~output);
  57.  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement