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 Diamond
- {
- class Diamond
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int upperRows = n / 2 + (n % 2); // add 1 or 0 - depending on even/odd
- // int firstRow = n / 2;
- string star = "*";
- if (n%2 == 0 )
- {
- star = "**";
- }
- string dash = new string ('-', (n- star.Length)/2);
- Console.WriteLine(dash+star+dash);
- for (int row = 0; row < upperRows-1; row++)
- {
- string middleDashes = new string('-',star.Length+row*2);
- string sideDashes = new string('-',(n-2-middleDashes.Length)/2);
- Console.WriteLine(sideDashes+"*"+middleDashes+"*"+sideDashes);
- }
- int downRows = (n / 2) - n % 2;
- for (int lastRows = 1; lastRows < downRows+1; lastRows++)
- {
- string sideDashes = new string('-', lastRows);
- string middleDashes = new string('-', (n - sideDashes.Length* 2)-2);
- Console.WriteLine(sideDashes + "*" + middleDashes + "*" + sideDashes);
- }
- dash = new string('-', (n - star.Length) / 2);
- Console.WriteLine(dash + star + dash);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement