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());
- var leftRight = (n - 1) / 2;
- for (int i = 1; i <= (n - 1) / 2; i++)
- { // Draw the top part
- Console.Write(new string('-', leftRight));
- Console.Write("*");
- var mid = n - 2 * leftRight - 2;
- if (mid >= 0)
- {
- Console.Write(new string('-', mid));
- Console.Write("*");
- }
- Console.WriteLine(new string('-', leftRight));
- leftRight--;
- } // TODO: Draw the bottom part
- }
- }
- }*/
- 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 stars;
- if (n % 2 == 0)
- stars = 2;
- else
- stars = 1;
- if (n > 2)
- {
- Console.WriteLine("{0}{1}{0}", new string('-', (n - stars) / 2), new string('*', stars));
- int dashes = ((n - stars) / 2) - 1;
- for (int i = 0; i < (n - 3) / 2; i++)
- {
- Console.WriteLine("{0}*{1}*{0}", new string('-', dashes), new string('-', stars + (2 * i)));
- dashes--;
- }
- Console.WriteLine("*{0}*", new string('-', n - 2));
- for (int i = ((n - 3) / 2) - 1; i >= 0; i--)
- {
- dashes++;
- Console.WriteLine("{0}*{1}*{0}", new string('-', dashes), new string('-', stars + (2 * i)));
- }
- Console.WriteLine("{0}{1}{0}", new string('-', (n - stars) / 2), new string('*', stars));
- }
- else
- Console.WriteLine(new string('*', stars));
- }
- }
- }
- /* for (int row = 0; row < n; row++)
- {
- Console.Write(new string('-', n - row - 1));
- for (int col = 0; col <= row; col++)
- {
- Console.Write('*');
- Console.Write('-');
- }
- Console.WriteLine();
- }
- for (int row = n - 1; row > 0; row--)
- {
- Console.Write(new string('-', n - row));
- for (int col = 0; col < row; col++)
- {
- Console.Write('*');
- Console.Write('-');
- }
- Console.WriteLine();
- }
- }
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment