Advertisement
leogvozdkov

зеброМетодЦвета

Aug 17th, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             DrawSquare(3, 3, 0, 0, ConsoleColor.Red, ConsoleColor.Green);
  15.             DrawSquare(5, 4, 10, 10, ConsoleColor.Yellow, ConsoleColor.Blue);
  16.             DrawSquare(7, 2, 20, 3, firstLineColor: ConsoleColor.Magenta, secondLineColor: ConsoleColor.Cyan);
  17.  
  18.         }
  19.  
  20.         static void DrawSquare(int sizeX, int sizeY, int posX, int posY, ConsoleColor firstLineColor, ConsoleColor secondLineColor)
  21.         {
  22.             for (int x = 0; x < sizeX; x++)
  23.             {
  24.                 for (int y = 0; y < sizeY; y++)
  25.                 {
  26.                     Console.ForegroundColor = (x + y) % 2 == 0  ? secondLineColor : firstLineColor;
  27.                     Console.SetCursorPosition(posX + x, posY + y);
  28.                     Console.Write("#");
  29.                 }
  30.             }
  31.         }
  32.     }
  33.  
  34.  
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement