Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- DrawSquare(3, 3, 0, 0, ConsoleColor.Red, ConsoleColor.Green);
- DrawSquare(5, 4, 10, 10, ConsoleColor.Yellow, ConsoleColor.Blue);
- DrawSquare(7, 2, 20, 3, firstLineColor: ConsoleColor.Magenta, secondLineColor: ConsoleColor.Cyan);
- }
- static void DrawSquare(int sizeX, int sizeY, int posX, int posY, ConsoleColor firstLineColor, ConsoleColor secondLineColor)
- {
- for (int x = 0; x < sizeX; x++)
- {
- for (int y = 0; y < sizeY; y++)
- {
- Console.ForegroundColor = (x + y) % 2 == 0 ? secondLineColor : firstLineColor;
- Console.SetCursorPosition(posX + x, posY + y);
- Console.Write("#");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement