Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BitBall
- {
- static void PrintMatrix(int[,] matrix)
- {
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- Console.Write(matrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- }
- static void Main()
- {
- int[,] topTeam = new int[8, 8];
- int[,] bottomTeam = new int[8, 8];
- int[,] afterFauls = new int[8, 8];
- int counterTop = 0;
- int counterBottom = 0;
- //enter Top Team field
- string[] topArr = new string[8];
- for (int i = 0; i < 8; i++)
- {
- topArr[i] = Convert.ToString(int.Parse(Console.ReadLine()), 2).PadLeft(8, '0');
- for (int j = 0; j < 8; j++)
- {
- topTeam[i, j] = topArr[i][j] == '0' ? 0 : 1;
- }
- }
- //enter Bottom Team field
- string[] bottomArr = new string[8];
- for (int i = 0; i < 8; i++)
- {
- bottomArr[i] = Convert.ToString(int.Parse(Console.ReadLine()), 2).PadLeft(8, '0');
- for (int j = 0; j < 8; j++)
- {
- bottomTeam[i, j] = bottomArr[i][j] == '0' ? 0 : 2;
- }
- }
- // Make field after Fauls
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- if (topTeam[i, j] > 0 && bottomTeam[i, j] > 0)
- {
- afterFauls[i, j] = 0;
- }
- else if (topTeam[i, j] > 0)
- {
- afterFauls[i, j] = topTeam[i, j];
- }
- else
- {
- afterFauls[i, j] = bottomTeam[i, j];
- }
- }
- }
- //PrintMatrix(topTeam);
- //PrintMatrix(bottomTeam);
- //PrintMatrix(afterFauls);
- //check for Top players success
- for (int j = 0; j < 8; j++)
- {
- for (int i = 0; i < 8; i++)
- {
- if (afterFauls[i, j] == 1)
- {
- break;
- }
- if (afterFauls[i, j] == 2)
- {
- counterBottom++; break;
- }
- }
- }
- //check for Bottom players success
- for (int j = 0; j < 8; j++)
- {
- for (int i = 7; i >= 0; i--)
- {
- if (afterFauls[i, j] == 2)
- {
- break;
- }
- if (afterFauls[i, j] == 1)
- {
- counterTop++; break;
- }
- }
- }
- //print results
- Console.WriteLine("{0}:{1}", counterTop, counterBottom);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement