Advertisement
nikolov_k

Lines

Dec 27th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 KB | None | 0 0
  1. using System;
  2.  
  3. class Lines
  4. {
  5.     static void Main()
  6.     {
  7.         int[,] n = new int[8, 8];
  8.         for (int i = 0; i < 8; i++)
  9.         {
  10.             int number = int.Parse(Console.ReadLine());
  11.             for (int j = 0; j < 8; j++)
  12.             {
  13.                 n[i, j] = (number & (1 << j)) >> j;
  14.             }
  15.         }
  16.         int countX = 0;
  17.         int maxX = 0;
  18.         int countMaxX = 0;
  19.         for (int i = 0; i < 8; i++)
  20.         {
  21.             for (int j = 0; j < 8; j++)
  22.             {
  23.                 if (n[i, j] == 1)
  24.                 {
  25.                     countX++;
  26.                 }
  27.                 else if (countX > 0)
  28.                 {
  29.                     if (countX > maxX)
  30.                     {
  31.                         maxX = countX;
  32.                         countMaxX = 1;
  33.                     }
  34.                     else if (countX == maxX)
  35.                     {
  36.                         countMaxX++;
  37.                     }
  38.                     countX = 0;
  39.                 }
  40.             }
  41.             if (countX > 0)
  42.             {
  43.                 if (countX > maxX)
  44.                 {
  45.                     maxX = countX;
  46.                     countMaxX = 1;
  47.                 }
  48.                 else if (countX == maxX)
  49.                 {
  50.                     countMaxX++;
  51.                 }
  52.                 countX = 0;
  53.             }
  54.         }
  55.         for (int j = 0; j < 8; j++)
  56.         {
  57.             for (int i = 0; i < 8; i++)
  58.             {
  59.                 if (n[i, j] == 1)
  60.                 {
  61.                     countX++;
  62.                 }
  63.                 else if (countX > 0)
  64.                 {
  65.                     if (countX > maxX)
  66.                     {
  67.                         maxX = countX;
  68.                         countMaxX = 1;
  69.                     }
  70.                     else if (countX == maxX)
  71.                     {
  72.                         countMaxX++;
  73.                     }
  74.                     countX = 0;
  75.                 }
  76.             }
  77.             if (countX > 0)
  78.             {
  79.                 if (countX > maxX)
  80.                 {
  81.                     maxX = countX;
  82.                     countMaxX = 1;
  83.                 }
  84.                 else if (countX == maxX)
  85.                 {
  86.                     countMaxX++;
  87.                 }
  88.                 countX = 0;
  89.             }
  90.         }
  91.         if (maxX == 1)
  92.         {
  93.             countMaxX = countMaxX / 2;
  94.         }
  95.         Console.WriteLine(maxX);
  96.         Console.WriteLine(countMaxX);
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement