Advertisement
leogvozdkov

цветной квадрат

Aug 10th, 2017
274
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. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.ForegroundColor = ConsoleColor.Yellow;
  14.             Console.BackgroundColor = ConsoleColor.Blue;
  15.             Console.Clear();
  16.  
  17.             int size_x = 13, size_y = 10;
  18.  
  19.             for (int x = 0; x < size_x; x++)
  20.             {
  21.  
  22.                 // четные - нечетные
  23.  
  24.                 for (int y = 0; y < size_y; y++)
  25.                 {
  26.                     Console.SetCursorPosition(x, y);
  27.                     if ((x + y) %  2 == 0)
  28.                     {
  29.                         Console.ForegroundColor = ConsoleColor.Green;
  30.                     }
  31.                     else
  32.                     {
  33.                         Console.ForegroundColor = ConsoleColor.Red;
  34.                     }
  35.                     Console.Write('#');
  36.                 }
  37.  
  38.                 ///// зеброй
  39.  
  40.                 for (int y = 0; y < size_y; y++)
  41.                 {
  42.                     Console.SetCursorPosition(x, y);
  43.                     if (y % 2 == 0)
  44.                     {
  45.                         Console.ForegroundColor = ConsoleColor.Green;
  46.                     }
  47.                     else
  48.                     {
  49.                         Console.ForegroundColor = ConsoleColor.Red;
  50.                     }
  51.                     Console.Write('#');
  52.                 }
  53.             }
  54.  
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement