Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
- namespace DrawingWithLoopsLiveDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
- int size = int.Parse(Console.ReadLine());
- int countOfStars = size % 2 == 0 ? 2 : 1;
- int countOfSideDashes = (size - countOfStars) / 2;
- string topAndBotDashes = new string('-', countOfSideDashes);
- string stars = new string('*', countOfStars);
- Console.WriteLine("{0}{1}{0}", topAndBotDashes, stars);
- countOfSideDashes--;
- int countOfMiddleDashes = countOfStars;
- int rows = (size - 1) / 2;
- for (int i = 0; i < rows; i++)
- {
- string sideDashes = new string('-', countOfSideDashes);
- string middleDashes = new string('-', countOfMiddleDashes);
- Console.WriteLine("{0}*{1}*{0}", sideDashes, middleDashes);
- countOfSideDashes--;
- countOfMiddleDashes += 2;
- }
- rows--;
- countOfSideDashes += 2;
- countOfMiddleDashes -= 4;
- for (int i = 0; i < rows; i++)
- {
- string sideDashes = new string('-', countOfSideDashes);
- string middleDashes = new string('-', countOfMiddleDashes);
- Console.WriteLine("{0}*{1}*{0}", sideDashes, middleDashes);
- countOfSideDashes++;
- countOfMiddleDashes -= 2;
- }
- if (size > 2)
- {
- Console.WriteLine("{0}{1}{0}", topAndBotDashes, stars);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement