Guest User

Untitled

a guest
May 26th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 KB | None | 0 0
  1.  
  2.             int[,] a = new int[2, 3];
  3.             for (int i = 0; i < a.GetLength(0);i++ )
  4.             {
  5.                 for (int j = 0; j < a.GetLength(1); j++)
  6.                 {
  7.                     // fill the array with ones to test only
  8.                     a[i, j] = 1;
  9.                 }
  10.             }
  11.             int count = 0;
  12.             for (int i = 0; i <= a.GetLength(0) - 2; i++)
  13.             {
  14.                 for (int j = 0; j <= a.GetLength(1) - 3; j++)
  15.                 {
  16.                     /*
  17.                      * check for this figure
  18.                      * 11
  19.                      *  11
  20.                      */
  21.                     Console.WriteLine(i + "  " + j);
  22.                     if ((a[i, j] == a[i, j + 1]) && (a[i + 1, j + 1] == a[i + 1, j + 2]) && (a[i, j + 1] == a[i + 1, j + 1]))
  23.                         count++;
  24.                    
  25.                 }
  26.             }
  27.             for (int i = 0; i <= a.GetLength(0) - 3; i++)
  28.             {
  29.                 for (int j = 0; j <= a.GetLength(1) - 2; j++)
  30.                 {
  31.                     /*
  32.                    * check for this figure
  33.                    * 1
  34.                    * 11
  35.                     * 1
  36.                    */
  37.                     Console.WriteLine(i + "  " + j);
  38.                     if ((a[i, j] == a[i+1, j ]) && (a[i + 1, j + 1] == a[i + 2, j + 1]) && (a[i+1, j ] == a[i + 1, j + 1]))
  39.                         count++;
  40.  
  41.                 }
  42.             }
  43.             for (int i = 1; i <= a.GetLength(0) - 1; i++)
  44.             {
  45.                 for (int j = 0; j <= a.GetLength(1) - 3; j++)
  46.                 {
  47.                     /*
  48.                     * check for this figure
  49.                     * 11
  50.                     *11
  51.                     */
  52.                     Console.WriteLine(i + "  " + j);
  53.                     if ((a[i, j] == a[i, j + 1]) && (a[i - 1, j + 1] == a[i - 1, j + 2]) && (a[i, j + 1] == a[i - 1, j + 1]))
  54.                         count++;
  55.  
  56.                 }
  57.             }
  58.             for (int i =0 ; i <= a.GetLength(0) - 3; i++)
  59.             {
  60.                 for (int j = 1; j <= a.GetLength(1) - 1; j++)
  61.                 {
  62.                   /*
  63.                   * check for this figure
  64.                   * 1
  65.                   *11
  66.                   *1
  67.                   */
  68.                     Console.WriteLine(i + "  " + j);
  69.                     if ((a[i, j] == a[i+1, j ]) && (a[i + 1, j - 1] == a[i + 2, j - 1]) && (a[i+1, j ] == a[i + 1, j - 1]))
  70.                         count++;
  71.  
  72.                 }
  73.             }
  74.             Console.WriteLine(count);
Add Comment
Please, Sign In to add comment