svetlozar_kirkov

X-Bits

Sep 19th, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace XBits
  4. {
  5.     class XBits
  6.     {
  7.         static void Main()
  8.         {
  9.             string[] binaries = new string[8];
  10.             int count = 0;
  11.  
  12.             for (int i = 0; i < 8; i++)
  13.             {
  14.                 int temp = int.Parse(Console.ReadLine());
  15.                 binaries[i] = Convert.ToString(temp, 2).PadLeft(32, '0');
  16.             }
  17.  
  18.            
  19.             for (int i = 0; i < binaries.Length; i++)
  20.             {
  21.                 for (int j = 0; j < 32 && i+2 < 8 && j+2 < 32 && j+1 < 32 && i+1 < 8; j++)
  22.                 {
  23.                     if (binaries[i][j] == '1' && binaries[i][j+1] == '0' && binaries[i][j+2] == '1' &&
  24.                         binaries[i+1][j] == '0' && binaries[i+1][j+1] == '1' && binaries[i+1][j+2] == '0' &&
  25.                         binaries[i+2][j] == '1' && binaries[i+2][j+1] == '0' && binaries[i+2][j+2] == '1')
  26.                     {
  27.                         count++;
  28.                     }
  29.                 }
  30.             }
  31.  
  32.             //foreach (var item in binaries)
  33.             //{
  34.             //    Console.WriteLine(item);
  35.             //}
  36.  
  37.             Console.WriteLine(count);
  38.  
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment