Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- char[,] topTeam = new char[8, 8];
- char[,] bottomTeam = new char[8, 8];
- char[,] field = new char[8, 8];
- int topScore = 0;
- int bottomScore = 0;
- // Read top team players
- for (int i = 0; i < 8; i++)
- {
- int number = int.Parse(Console.ReadLine());
- for (int j = 7; j >= 0; j--)
- {
- int bit = (number >> j) & 1;
- if (bit == 1)
- {
- topTeam[i, j] = 'T';
- }
- else
- {
- topTeam[i, j] = ' ';
- }
- }
- }
- // Read bottom team players
- for (int i = 0; i < 8; i++)
- {
- int number = int.Parse(Console.ReadLine());
- for (int j = 7; j >= 0; j--)
- {
- int bit = (number >> j) & 1;
- if (bit == 1)
- {
- bottomTeam[i, j] = 'B';
- }
- else
- {
- bottomTeam[i, j] = ' ';
- }
- }
- }
- // Create common field
- for (int i = 0; i < 8; i++)
- {
- for (int j = 7; j >= 0; j--)
- {
- char topPlayer = topTeam[i, j];
- char bottomPlayer = bottomTeam[i, j];
- if (topPlayer == ' ' && bottomPlayer == ' ')
- {
- field[i, j] = ' ';
- }
- else if (topPlayer == 'T' && bottomPlayer == 'B')
- {
- field[i, j] = ' ';
- }
- else if (topPlayer == 'T' && bottomPlayer == ' ')
- {
- field[i, j] = 'T';
- }
- else if (topPlayer == ' ' && bottomPlayer == 'B')
- {
- field[i, j] = 'B';
- }
- }
- }
- // Get bottom score - count columns from top to bottom
- for (int col = 7; col >= 0; col--)
- {
- for (int row = 0; row < 8; row++)
- {
- if (field[row, col] == 'T')
- {
- break;
- }
- else if (field[row, col] == 'B')
- {
- bottomScore++;
- break;
- }
- }
- }
- // Get top score - count columns from bottom to top
- for (int col = 7; col >= 0; col--)
- {
- for (int row = 7; row >= 0; row--)
- {
- if (field[row, col] == 'T')
- {
- topScore++;
- break;
- }
- else if (field[row, col] == 'B')
- {
- break;
- }
- }
- }
- // Print score
- Console.WriteLine("{0}:{1}", topScore, bottomScore);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement