Advertisement
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;
- class Neurons
- {
- static void Main()
- {
- List<long> crossSections = new List<long>();
- long n = long.Parse(Console.ReadLine());
- while (n!=-1)
- {
- crossSections.Add(n);
- n = long.Parse(Console.ReadLine());
- }
- for (int i = 0; i < crossSections.Count; i++)
- {
- if (crossSections[i]!=0)
- {
- List<int> bitPosition = new List<int>();
- for (int j = 0; j < 32; j++)
- {
- if ((crossSections[i] & 1 << j) != 0)
- {
- crossSections[i] = crossSections[i] & (~(1 << j));
- bitPosition.Add(j);
- }
- else
- {
- crossSections[i] = crossSections[i] | (1 << j);
- }
- }
- for (int z = 0; z < bitPosition.Min(); z++)
- {
- crossSections[i] = crossSections[i] & (~(1 << z));
- }
- for (int k = bitPosition.Max() + 1; k < 32; k++)
- {
- crossSections[i] = crossSections[i] & (~(1 << k));
- }
- }
- }
- for (int s = 0; s < crossSections.Count; s++)
- {
- Console.WriteLine(crossSections[s]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement