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;
- namespace Lines
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] inputArray = new string[8];
- int biggerLine = 0;
- int bigLineCounter = 0;
- int rowCounter = 0;
- int columnCounter = 0;
- int horizontalLines = 0;
- int[] lines = new int[64];
- for (int i = 0; i < 8; i++)
- {
- inputArray[i] = Convert.ToString(byte.Parse(Console.ReadLine()), 2).PadLeft(8,'0');
- }
- string[,] matrix = new string[8, 8];
- //matrix input of digits in binary
- for (int row = 0; row < 8; row++)
- {
- for (int col = 0; col < 8; col++)
- {
- matrix[row, col] = Convert.ToString(inputArray[row][col]);
- }
- }
- //print
- /*for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- Console.Write(matrix[i,j]);
- }
- Console.WriteLine();
- }*/
- //rowcounter
- for (int row = 0; row < 8; row++)
- {
- for (int col = 0; col < 8; col++)
- {
- if (matrix[row, col] == "1")
- {
- rowCounter++;
- }
- if ((matrix[row,col]!="1")||((matrix[row,col]=="1")&&col==7))
- {
- if (rowCounter > 0)
- {
- lines[horizontalLines] = rowCounter;
- rowCounter = 0;
- horizontalLines++;
- }
- }
- }
- }
- //columncounter
- for (int col = 0; col < 8; col++)
- {
- for (int row = 0; row < 8; row++)
- {
- if (matrix[row, col] == "1")
- {
- columnCounter++;
- }
- if ((matrix[row, col] != "1") || ((matrix[row, col] == "1") && row == 7))
- {
- if (columnCounter > 0)
- {
- lines[horizontalLines] = columnCounter;
- columnCounter = 0;
- horizontalLines++;
- }
- }
- }
- }
- //line array
- /*for (int i = 0; i < lines.Length; i++)
- {
- Console.Write(" "+lines[i]);
- }
- Console.WriteLine();*/
- //line lenght checker
- for (int i = 0; i < 64; i++)
- {
- if (lines[i]>biggerLine)
- {
- biggerLine = lines[i];
- }
- }
- //big line counting
- for (int i = 0; i < 64; i++)
- {
- if(lines[i]==biggerLine)
- {
- bigLineCounter++;
- }
- }
- //output
- if ( biggerLine==1)
- {
- bigLineCounter = bigLineCounter / 2;
- }
- Console.WriteLine(biggerLine);
- Console.WriteLine(bigLineCounter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement