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==1)
- {
- star = "*";
- Console.WriteLine(star);
- return;
- }
- if (n==2)
- {
- star = "**";
- Console.WriteLine(star);
- return;
- }
- 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-(n/2+2);// promenena formula
- for (int lastRows = 1; lastRows <= downRows ; 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