Advertisement
fbinnzhivko

04.01.Tetris

Mar 11th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.63 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main(string[] args)
  5.     {
  6.         string[] input = Console.ReadLine().Split(' ');
  7.         int rowInput = int.Parse(input[0]);
  8.         int colInput = int.Parse(input[1]);
  9.         char[,] matrix = new char[rowInput, colInput];
  10.         string inpuLine;
  11.         int row, col = new int();
  12.         for (row = 0; row < rowInput; row++)
  13.         {
  14.             inpuLine = Console.ReadLine();
  15.             for (col = 0; col < colInput; col++)
  16.             {
  17.                 matrix[row, col] = inpuLine[col];
  18.                 // Console.Write("{0}",matrix[row, col]);
  19.             }
  20.             // Console.WriteLine();
  21.         }
  22.         int countI = 0;
  23.         int countL = 0;
  24.         int countJ = 0;
  25.         int countO = 0;
  26.         int countZ = 0;
  27.         int countS = 0;
  28.         int countT = 0;
  29.         for (row = 0; row < rowInput - 3; row++)
  30.         {
  31.             for (col = 0; col < colInput; col++)
  32.             {
  33.                 if (matrix[row, col] == 'o' && matrix[row + 1, col] == 'o' &&
  34.                     matrix[row + 2, col] == 'o' && matrix[row + 3, col] == 'o')
  35.                 {
  36.                     countI++;
  37.                 }
  38.             }
  39.         }
  40.         for (row = 0; row < rowInput - 2; row++)
  41.         {
  42.             for (col = 0; col < colInput - 1; col++)
  43.             {
  44.                 if (matrix[row, col] == 'o' && matrix[row + 1, col] == 'o' &&
  45.                     matrix[row + 2, col] == 'o' && matrix[row + 2, col + 1] == 'o')
  46.                 {
  47.                     countL++;
  48.                 }
  49.             }
  50.         }
  51.         for (row = 0; row < rowInput - 2; row++)
  52.         {
  53.             for (col = 1; col < colInput; col++)
  54.             {
  55.                 if (matrix[row, col] == 'o' && matrix[row + 1, col] == 'o' &&
  56.                     matrix[row + 2, col] == 'o' && matrix[row + 2, col - 1] == 'o')
  57.                 {
  58.                     countJ++;
  59.                 }
  60.             }
  61.         }
  62.         for (row = 0; row < rowInput - 1; row++)
  63.         {
  64.             for (col = 0; col < colInput - 1; col++)
  65.             {
  66.                 if (matrix[row, col] == 'o' && matrix[row + 1, col] == 'o' &&
  67.                     matrix[row, col + 1] == 'o' && matrix[row + 1, col + 1] == 'o')
  68.                 {
  69.                     countO++;
  70.                 }
  71.             }
  72.         }
  73.         for (row = 0; row < rowInput - 1; row++)
  74.         {
  75.             for (col = 0; col < colInput - 2; col++)
  76.             {
  77.                 if (matrix[row, col] == 'o' && matrix[row, col + 1] == 'o' &&
  78.                     matrix[row + 1, col + 1] == 'o' && matrix[row + 1, col + 2] == 'o')
  79.                 {
  80.                     countZ++;
  81.                 }
  82.             }
  83.         }
  84.         for (row = 1; row < rowInput; row++)
  85.         {
  86.             for (col = 0; col < colInput - 2; col++)
  87.             {
  88.                 if (matrix[row, col] == 'o' && matrix[row, col + 1] == 'o' &&
  89.                     matrix[row - 1, col + 1] == 'o' && matrix[row - 1, col + 2] == 'o')
  90.                 {
  91.                     countS++;
  92.                 }
  93.             }
  94.         }
  95.         for (row = 0; row < rowInput - 1; row++)
  96.         {
  97.             for (col = 0; col < colInput - 2; col++)
  98.             {
  99.                 if (matrix[row, col] == 'o' && matrix[row, col + 1] == 'o' &&
  100.                     matrix[row + 1, col + 1] == 'o' && matrix[row, col + 2] == 'o')
  101.                 {
  102.                     countT++;
  103.                 }
  104.             }
  105.         }
  106.         Console.WriteLine("I:{0}, L:{1}, J:{2}, O:{3}, Z:{4}, S:{5}, T:{6}", countI, countL, countJ, countO, countZ, countS, countT);
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement