Advertisement
jokerbg

Bit Ball

Mar 8th, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.83 KB | None | 0 0
  1. using System;
  2. class BitBall
  3. {
  4.     static void PrintMatrix(int[,] matrix)
  5.     {
  6.         for (int i = 0; i < 8; i++)
  7.         {
  8.             for (int j = 0; j < 8; j++)
  9.             {
  10.                 Console.Write(matrix[i, j] + "  ");
  11.             }
  12.             Console.WriteLine();
  13.         }
  14.         Console.WriteLine();
  15.     }
  16.  
  17.     static void Main()
  18.     {
  19.         int[,] topTeam = new int[8, 8];
  20.         int[,] bottomTeam = new int[8, 8];
  21.         int[,] afterFauls = new int[8, 8];
  22.         int counterTop = 0;
  23.         int counterBottom = 0;
  24.  
  25.         //enter Top Team field
  26.         string[] topArr = new string[8];
  27.         for (int i = 0; i < 8; i++)
  28.         {
  29.             topArr[i] = Convert.ToString(int.Parse(Console.ReadLine()), 2).PadLeft(8, '0');
  30.             for (int j = 0; j < 8; j++)
  31.             {
  32.                 topTeam[i, j] = topArr[i][j] == '0' ? 0 : 1;
  33.             }
  34.         }
  35.  
  36.         //enter Bottom Team field
  37.         string[] bottomArr = new string[8];
  38.         for (int i = 0; i < 8; i++)
  39.         {
  40.             bottomArr[i] = Convert.ToString(int.Parse(Console.ReadLine()), 2).PadLeft(8, '0');
  41.             for (int j = 0; j < 8; j++)
  42.             {
  43.                 bottomTeam[i, j] = bottomArr[i][j] == '0' ? 0 : 2;
  44.             }
  45.         }
  46.  
  47.         // Make field after Fauls
  48.         for (int i = 0; i < 8; i++)
  49.         {
  50.             for (int j = 0; j < 8; j++)
  51.             {
  52.                 if (topTeam[i, j] > 0 && bottomTeam[i, j] > 0)
  53.                 {
  54.                     afterFauls[i, j] = 0;
  55.                 }
  56.                 else if (topTeam[i, j] > 0)
  57.                 {
  58.                     afterFauls[i, j] = topTeam[i, j];
  59.                 }
  60.                 else
  61.                 {
  62.                     afterFauls[i, j] = bottomTeam[i, j];
  63.                 }
  64.             }
  65.         }
  66.         //PrintMatrix(topTeam);
  67.         //PrintMatrix(bottomTeam);
  68.         //PrintMatrix(afterFauls);
  69.  
  70.         //check for Top players success
  71.         for (int j = 0; j < 8; j++)
  72.         {
  73.             for (int i = 0; i < 8; i++)
  74.             {
  75.                 if (afterFauls[i, j] == 1)
  76.                 {
  77.                     break;
  78.                 }
  79.                 if (afterFauls[i, j] == 2)
  80.                 {
  81.                     counterBottom++; break;
  82.                 }
  83.             }
  84.         }
  85.  
  86.         //check for Bottom players success
  87.         for (int j = 0; j < 8; j++)
  88.         {
  89.             for (int i = 7; i >= 0; i--)
  90.             {
  91.                 if (afterFauls[i, j] == 2)
  92.                 {
  93.                     break;
  94.                 }
  95.                 if (afterFauls[i, j] == 1)
  96.                 {
  97.                     counterTop++; break;
  98.                 }
  99.             }
  100.         }
  101.  
  102.         //print results
  103.         Console.WriteLine("{0}:{1}", counterTop, counterBottom);
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement