Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _3.TheExplorer
- {
- using System;
- public class TheExplorer
- {
- public static void Main(string[] args)
- {
- checked
- {
- int numN = int.Parse(Console.ReadLine());
- string hyphenSequenceTopAndBottom = new string('-', numN / 2);
- string hyphenSequenceOnMiddleRow = new string('-', numN - 2);
- // Print Top row:
- Console.WriteLine("{0}{1}{0}", hyphenSequenceTopAndBottom, '*');
- // Print rows betweens Top and Bottom rows:
- for (int row = 1; row < numN - 1; row++)
- {
- if (row == numN / 2)
- {
- Console.WriteLine("{0}{1}{0}", '*', hyphenSequenceOnMiddleRow);
- }
- else
- {
- // Calculating lenght of Internal hyphen sequences:
- int lenghtInternalHyphenSequence;
- if (row < numN / 2)
- {
- lenghtInternalHyphenSequence = (row * 2) - 1;
- }
- else
- {
- lenghtInternalHyphenSequence = ((numN - row - 1) * 2) - 1;
- }
- // Create Internal hyphen sequence:
- string internalHyphenSequence = new string('-', lenghtInternalHyphenSequence);
- // Calculating and create External hyphen sequence:
- int lenghtExternalHyphenSequence = (numN - 2 - lenghtInternalHyphenSequence) / 2;
- string externalHyphenSequence = new string('-', lenghtExternalHyphenSequence);
- // Print current row:
- Console.WriteLine("{0}{1}{2}{1}{0}", externalHyphenSequence, '*', internalHyphenSequence);
- }
- }
- // Print Bottom row:
- Console.WriteLine("{0}{1}{0}", hyphenSequenceTopAndBottom, '*');
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement