Advertisement
Vladimir76

задача 15

Jan 1st, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.36 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace LesonLoop_2
  7. {
  8.     class Loop_2
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Console.Write("n = ");
  13.             int n = int.Parse(Console.ReadLine());
  14.             int p3 = 3;
  15.             int p4 = 4;
  16.             int p5 = 5;
  17.             int p24 = 24;
  18.             int p25 = 25;
  19.             int p26 = 26;
  20.  
  21.             int maskP3 = 1 << p3;
  22.             int maskP4 = 1 << p4;
  23.             int maskP5 = 1 << p5;
  24.             int maskP24 = 1 << p24;
  25.             int maskP25 = 1 << p25;
  26.             int maskP26 = 1 << p26;
  27.  
  28.             int newN3 = n&(~maskP3);
  29.             int newN4 = n&(~maskP4);
  30.             int newN5 = n&(~maskP5);
  31.             int newN24 = n&(~maskP24);
  32.             int newN25 = n&(~maskP25);
  33.             int newN26 = n&(~maskP26);
  34.  
  35.             int bit3 = newN3 ^ n;
  36.             int bit4 = newN4 ^ n;
  37.             int bit5 = newN5 ^ n;
  38.             int bit24 = newN24 ^ n;
  39.             int bit25 = newN25 ^ n;
  40.             int bit26 = newN26 ^ n;
  41.  
  42.             if ((bit3 >> p3) == (bit24 >> p24))
  43.             {
  44.                 if ((bit4 >> p4) == (bit25 >> p25))
  45.                 {
  46.                     if ((bit5 >> p5) == (bit26 >> p26))
  47.                     {
  48.                         Console.WriteLine("n= " + n);
  49.                     }
  50.                     else
  51.                     {
  52.                         int endBit5 = n ^ maskP5;
  53.                         int endBit526 = endBit5 ^ maskP26;
  54.                         Console.WriteLine("endBit526 = " + endBit526);
  55.                     }
  56.                 }
  57.                 else
  58.                 {
  59.                     int endBit4 = n ^ maskP4;
  60.                     int endBit425 = endBit4 ^ maskP25;
  61.                     int endBit425526 = (endBit425 ^ maskP5) ^ maskP26;
  62.                     Console.WriteLine(((bit5 >> p5) == (bit26 >> p26)) ? ("endBit425 = " + endBit425) : ("endBit425526 = " + endBit425526));
  63.                 }
  64.             }
  65.             else
  66.             {
  67.                 if ((bit4 >> p4) == (bit25 >> p25))
  68.                 {
  69.                     if ((bit5 >> p5) == (bit26 >> p26))
  70.                     {
  71.                         int endBit3 = n ^ maskP3;
  72.                         int endBit324 = endBit3 ^ maskP24;
  73.                         Console.WriteLine("endBit324 = " + endBit324);
  74.                     }
  75.                     else
  76.                     {
  77.  
  78.                         int endBit3 = n ^ maskP3;
  79.                         int endBit324 = endBit3 ^ maskP24;
  80.                         int endBit3245 = endBit324 ^ maskP5;
  81.                         int endBit324526 = endBit3245 ^ maskP26;
  82.                         Console.WriteLine("endBit324526 = " + endBit324526);
  83.                     }
  84.                 }
  85.                 else
  86.                 {
  87.                     int endBit3 = n ^ maskP3;
  88.                     int endBit324 = endBit3 ^ maskP24;
  89.                     int endBit3244 = endBit324 ^ maskP4;
  90.                     int endBit324425 = endBit3244 ^ maskP25;
  91.                     int endBit324425526 = ((endBit324425^maskP5)^maskP26);
  92.                     Console.WriteLine(
  93.                         ((bit5>>p5)==(bit26>>p26)) ? ("endBit324425 = " + endBit324425) : ("endBit324425526 = " + endBit324425526));
  94.                 }
  95.             }
  96.         }
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement