Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ExamTasks
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[,] matrix = new int[7, 7];
- int i = 0;
- int j = 0;
- int counter = 1;
- while (counter < 49)
- {
- while (j < 7)
- {
- if (matrix[i, j] != 0)
- break;
- else
- {
- matrix[i, j] = counter;
- counter++;
- j++;
- }
- }
- j--;
- i++;
- while (i < 7)
- {
- if (matrix[i, j] != 0)
- break;
- else
- {
- matrix[i, j] = counter;
- counter++;
- i++;
- }
- }
- i--;
- j--;
- while (j >= 0)
- {
- if (matrix[i, j] != 0)
- break;
- else
- {
- matrix[i, j] = counter;
- counter++;
- j--;
- }
- }
- i--;
- j++;
- while (i >= 0)
- {
- if (matrix[i, j] != 0)
- break;
- else
- {
- matrix[i, j] = counter;
- counter++;
- i--;
- }
- }
- i++;
- j++;
- }
- matrix[i, j] = 49;
- for (int k = 0; k < 7; k++)
- {
- for (int l = 0; l < 7; l++)
- Console.Write(matrix[k, l] + "\t");
- Console.WriteLine("");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement