Advertisement
TimmyChannel

Дыч

May 26th, 2022
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1.  static int[,][,] OnBlocks(int[,] Matrix)
  2.         {
  3.             //Верхний левый угол
  4.             int NewSize = (int)Math.Sqrt(Matrix.Length) >> 1;
  5.             int DefaultSize = (int)Math.Sqrt(Matrix.Length);
  6.             int[,][,] ResultMatrix = new int[2, 2][,];
  7.             var s1 = new int[NewSize,NewSize];
  8.             var s2 = new int[NewSize,NewSize];
  9.             var s3 = new int[NewSize,NewSize];
  10.             var s4 = new int[NewSize,NewSize];
  11.             for (int i = 0; i < DefaultSize >> 1; i++)
  12.             {
  13.                 for (int j = 0; j < DefaultSize >> 1; j++)
  14.                 {
  15.                         s1[i, j] = Matrix[i, j];
  16.                 }
  17.             }
  18.             //Верхний правый угол
  19.             for (int i = 0; i < DefaultSize >> 1; i++)
  20.             {
  21.                 for (int j = DefaultSize >> 1; j < DefaultSize; j++)
  22.                 {
  23.                     s2[i, j - NewSize] = Matrix[i, j];
  24.                 }
  25.             }
  26.             //Нижний левый угол
  27.             for (int i = DefaultSize >> 1; i < DefaultSize; i++)
  28.             {
  29.                 for (int j = 0; j < (DefaultSize >> 1); j++)
  30.                 {
  31.                     s3[i - NewSize, j] = Matrix[i, j];
  32.                 }
  33.             }
  34.             //Нижнинй правый угол  
  35.             for (int i = DefaultSize >> 1; i < DefaultSize; i++)
  36.             {
  37.                 for (int j = DefaultSize >> 1; j < DefaultSize; j++)
  38.                 {
  39.                     s4[i - NewSize, j - NewSize] = Matrix[i, j];
  40.                 }
  41.             }
  42.             ResultMatrix[0, 0] = s1;
  43.             ResultMatrix[0, 1] = s2;
  44.             ResultMatrix[1, 0] = s3;
  45.             ResultMatrix[1, 1] = s4;
  46.             return ResultMatrix;
  47.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement