Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Lines
- {
- static void Main()
- {
- byte[] countVertical = new byte[8];
- byte previousBit = 0;
- byte lenght = 0;
- byte countHorizontal = 0;
- byte result = 0;
- for (byte i = 0; i < 8; i++)
- {
- countHorizontal = 0;
- byte number = byte.Parse(Console.ReadLine());
- for (int j = 0; j < 8; j++)
- {
- byte mask = (byte)(1 << j);
- byte bit = (byte)(number & mask);
- bit = (byte)(bit >> j);
- //Horizontal lines
- if (bit == 1)
- {
- countHorizontal++;
- if (countHorizontal > lenght)
- {
- lenght = countHorizontal;
- result = 0;
- }
- previousBit = bit;
- if (j == 7 && countHorizontal == lenght)
- {
- result++;
- }
- }
- else
- {
- if (bit != previousBit && countHorizontal == lenght)
- {
- result++;
- }
- countHorizontal = 0;
- }
- //Vertikal lines
- if (bit == 1)
- {
- countVertical[j] ++;
- if (countVertical[j] > lenght)
- {
- lenght = countVertical[j];
- result = 0;
- }
- if (i == 7 && countVertical[j] == lenght && lenght != 1)
- {
- result++;
- }
- }
- else
- {
- if (bit != countVertical[j] && countVertical[j] == lenght && lenght != 1)
- {
- result++;
- }
- countVertical[j] = 0;
- }
- }
- }
- Console.WriteLine(lenght);
- Console.WriteLine(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement