Advertisement
Guest User

Neoruons

a guest
Dec 4th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.03 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.     class Neurons
  8.     {
  9.         static void Main()
  10.         {
  11.            
  12.             List<long> crossSections = new List<long>();
  13.             long n = long.Parse(Console.ReadLine());
  14.            
  15.             while (n!=-1)
  16.             {
  17.                 crossSections.Add(n);
  18.                 n = long.Parse(Console.ReadLine());
  19.             }
  20.            
  21.            
  22.                 for (int i = 0; i < crossSections.Count; i++)                
  23.                 {
  24.                     if (crossSections[i]!=0)
  25.                     {
  26.                         List<int> bitPosition = new List<int>();
  27.                    
  28.                         for (int j = 0; j < 32; j++)
  29.                         {
  30.                             if ((crossSections[i] & 1 << j) != 0)
  31.                             {
  32.                                 crossSections[i] = crossSections[i] & (~(1 << j));
  33.                                 bitPosition.Add(j);              
  34.                             }
  35.                             else
  36.                             {
  37.                                 crossSections[i] = crossSections[i] | (1 << j);
  38.                             }
  39.  
  40.                         }
  41.                        
  42.                         for (int z = 0; z < bitPosition.Min(); z++)
  43.                         {
  44.                             crossSections[i] = crossSections[i] & (~(1 << z));
  45.                         }
  46.                         for (int k = bitPosition.Max() + 1; k < 32; k++)
  47.                         {
  48.                             crossSections[i] = crossSections[i] & (~(1 << k));
  49.                         }
  50.  
  51.                     }
  52.                    
  53.                 }
  54.                                  
  55.                 for (int s = 0; s < crossSections.Count; s++)
  56.                 {
  57.                     Console.WriteLine(crossSections[s]);
  58.                    
  59.                 }
  60.            
  61.         }
  62.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement