fbinnzhivko

08.01 Diamonds

May 16th, 2016
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. public class Diamonds
  3. {
  4.     static void Main()
  5.     {
  6.         int size = int.Parse(Console.ReadLine());
  7.  
  8.         for (int row = 0; row < size; row++)
  9.         {
  10.             for (int col = 0; col < size; col++)
  11.             {
  12.                 if (row + col == size / 2)
  13.                 {
  14.                     Console.Write('*');
  15.                 }
  16.                 else if (row + col == (size - 1) + (size / 2))
  17.                 {
  18.                     Console.Write('*');
  19.                 }
  20.                 else if (row - col == size / 2)
  21.                 {
  22.                     Console.Write('*');
  23.                 }
  24.                 else if (row - col == -(size / 2))
  25.                 {
  26.                     Console.Write('*');
  27.                 }
  28.                 else
  29.                 {
  30.                     Console.Write('-');
  31.                 }
  32.             }
  33.             Console.WriteLine();
  34.         }
  35.     }
  36. }
Add Comment
Please, Sign In to add comment