Advertisement
Lauda

Untitled

Feb 14th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ConsoleRectangle
  5. {
  6.     public class Program
  7.     {
  8.         private static void Main()
  9.         {
  10.             {
  11.                 const int width = 30;
  12.                 const int height = 15;
  13.                 const char symbol = '▓';
  14.                 Console.WriteLine();
  15.  
  16.                 Enumerable.Range(0, 15).SelectMany(row => Enumerable.Range(0, 30), (row, col) => new { row, col }).Where(@t => @t.col == 0 || @t.col == 30 || @t.row == 0 || @t.row == 15).Select(x => x); // test wip
  17.  
  18.                 var totalRows = 0;
  19.                 var totalCols = 0;
  20.  
  21.                 for (var y = 0; y <= height - 1; y++)
  22.                 {
  23.                     totalRows++;
  24.                     for (var x = 0; x <= width - 1; x++)
  25.                     {
  26.                         if (x != 0 && x != width - 1 && y != 0 && y != height - 1)
  27.                             Console.ForegroundColor = ConsoleColor.Yellow;
  28.                         else
  29.                             Console.ForegroundColor = ConsoleColor.Green;
  30.  
  31.                         Console.Write(symbol);
  32.                         totalCols++;
  33.                     }
  34.                     Console.WriteLine("");
  35.                 }
  36.  
  37.                 Console.WriteLine($"Total rows = {totalRows}, total cols = {totalCols / 15}");
  38.                 Console.ReadLine();
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement