Advertisement
Schnuk

690

Jan 17th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace ExamTasks
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int[,] matrix = new int[7, 7];
  12.             int i = 0;
  13.             int j = 0;
  14.             int counter = 1;
  15.             while (counter < 49)
  16.             {
  17.                 while (j < 7)
  18.                 {
  19.                     if (matrix[i, j] != 0)
  20.                         break;
  21.                     else
  22.                     {
  23.                         matrix[i, j] = counter;
  24.                         counter++;
  25.                         j++;
  26.                     }
  27.                 }
  28.                 j--;
  29.                 i++;
  30.                 while (i < 7)
  31.                 {
  32.                     if (matrix[i, j] != 0)
  33.                         break;
  34.                     else
  35.                     {
  36.                         matrix[i, j] = counter;
  37.                         counter++;
  38.                         i++;
  39.                     }
  40.                 }
  41.                 i--;
  42.                 j--;
  43.                 while (j >= 0)
  44.                 {
  45.                     if (matrix[i, j] != 0)
  46.                         break;
  47.                     else
  48.                     {
  49.                         matrix[i, j] = counter;
  50.                         counter++;
  51.                         j--;
  52.                     }
  53.                 }
  54.                 i--;
  55.                 j++;
  56.                 while (i >= 0)
  57.                 {
  58.                     if (matrix[i, j] != 0)
  59.                         break;
  60.                     else
  61.                     {
  62.                         matrix[i, j] = counter;
  63.                         counter++;
  64.                         i--;
  65.                     }
  66.                 }
  67.                 i++;
  68.                 j++;
  69.             }
  70.             matrix[i, j] = 49;
  71.             counter = 0;
  72.             int[] b = new int[49];
  73.             int k = 1;
  74.             i = 0;
  75.             j = 0;
  76.             while (counter < 48)
  77.             {
  78.                 while (j < 8 - k)
  79.                 {
  80.                     b[counter] = matrix[i, j];
  81.                     counter++;
  82.                     j++;
  83.                 }
  84.                 j--;
  85.                 i++;
  86.                 while (i < 7 - k)
  87.                 {
  88.                     b[counter] = matrix[i, j];
  89.                     counter++;
  90.                     i++;
  91.                 }
  92.                 while (j >= k - 1)
  93.                 {
  94.                     b[counter] = matrix[i, j];
  95.                     counter++;
  96.                     j--;
  97.                 }
  98.                 i--;
  99.                 j++;
  100.                 while (i >= k)
  101.                 {
  102.                     b[counter] = matrix[i, j];
  103.                     counter++;
  104.                     i--;
  105.                 }
  106.                 i++;
  107.                 j++;
  108.                 k++;
  109.             }
  110.             b[counter++] = matrix[i, j];
  111.             for (int f = 0; f < 49; f++)
  112.                 Console.Write(b[f] + "\t");
  113.         }
  114.     }
  115. }
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement