Advertisement
BorislavBorisov

37.01.UK Flag мое най-добро матрица

Feb 5th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using System;
  2. class SunGlasses
  3. {
  4.     static void Main()
  5.     {
  6.         int N = 5;
  7.         char[,] matrix = new char[N, N];
  8.         int leftSlash = 0, rightSlash = N - 1;
  9.  
  10.         for (int row = 0; row < matrix.GetLength(0); row++)
  11.         {
  12.             for (int col = 0; col < matrix.GetLength(1); col++)
  13.             {
  14.                 if (leftSlash == col && row != N / 2)
  15.                 {
  16.                     matrix[row, col] = '\\';
  17.                 }
  18.                 else if (row == N / 2)
  19.                 {
  20.                     if (col < N / 2)
  21.                     {
  22.                         matrix[row,col] = '-';
  23.                     }
  24.                     else if (col > N / 2)
  25.                     {
  26.                         matrix[row, col] = '-';
  27.                     }
  28.                     else
  29.                     {
  30.                         matrix[row, col] = '*';
  31.                     }
  32.                 }
  33.                 else if (rightSlash == col && row != N / 2)
  34.                 {
  35.                     matrix[row,col] = '/';
  36.                 }
  37.                 else if (col == N / 2 && row != N / 2)
  38.                 {
  39.                     matrix[row, col] = '|';
  40.                 }
  41.                 else//точките
  42.                 {
  43.                     matrix[row, col] = '.';
  44.                 }
  45.             }
  46.             rightSlash--;
  47.             leftSlash++;
  48.         }
  49.  
  50.         for (int row = 0; row < matrix.GetLength(0); row++)
  51.         {
  52.             for (int col = 0; col < matrix.GetLength(1); col++)
  53.             {
  54.                 Console.Write(matrix[row,col]);
  55.             }
  56.             Console.WriteLine();
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement