archangelmihail

BitBall

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