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 Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int stars = 1;
- int rows = n;
- if (n % 2 == 0)
- {
- stars = 2;
- rows = n - 1;
- }
- int sides = (n - stars) / 2;
- int middle = stars - 2;
- string row;
- for (int i = 1; i <= rows / 2 + 1; i++)
- {
- if (i == 1)
- {
- row = $"{new string('-', sides)}{new string('*', stars)}{new string('-', sides)}";
- }
- else
- {
- row = $"{new string('-', sides)}*{new string('-', middle)}*{new string('-', sides)}";
- }
- sides--;
- middle += 2;
- Console.WriteLine(row);
- }
- sides += 2;
- middle -= 4;
- for (int i = 1; i <= rows / 2; i++)
- {
- if (i == rows / 2)
- {
- row = $"{new string('-', sides)}{new string('*', stars)}{new string('-', sides)}";
- }
- else
- {
- row = $"{new string('-', sides)}*{new string('-', middle)}*{new string('-', sides)}";
- }
- sides++;
- middle -= 2;
- Console.WriteLine(row);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment