BorislavBorisov

36.01 Sun Glasses най-добро матрица

Jan 29th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 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 * 5];
  8.  
  9.         for (int row = 0; row < matrix.GetLength(0); row++)
  10.         {
  11.             for (int col = 0; col < matrix.GetLength(1); col++)
  12.             {
  13.                 if (row == 0 || row == matrix.GetLength(0) - 1)
  14.                 {
  15.                     if (col < N * 2 || col >= N * 3)
  16.                     {
  17.                         matrix[row, col] = '*';
  18.                     }
  19.                 }
  20.                 else
  21.                 {
  22.                     if(col == 0 || col == N * 2 - 1
  23.                         || col == N * 3 || col == N * 5 - 1)
  24.                     {
  25.                         matrix[row, col] = '*';
  26.                     }
  27.                     else if (col < N * 2 || col > N * 3)//за стъклата
  28.                     {
  29.                         matrix[row, col] = '/';
  30.                     }
  31.                     else if (row == N / 2 && col >= N * 2 && col < N * 3)
  32.                     {
  33.                         matrix[row, col] = '|';
  34.                     }
  35.                     else
  36.                     {
  37.                         matrix[row, col] = ' ';
  38.                     }
  39.                 }
  40.             }
  41.         }
  42.  
  43.         for (int row = 0; row < matrix.GetLength(0); row++)
  44.         {
  45.             for (int col = 0; col < matrix.GetLength(1); col++)
  46.             {
  47.                 Console.Write(matrix[row,col]);
  48.             }
  49.             Console.WriteLine();
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment