Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Make a swaastik
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Swaastik
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter any number : ");
- int i;
- if(int.TryParse(Console.ReadLine(),out i))
- {
- int x = 0, y = 3;
- bool[] id = new bool[] {false,true};
- for (int j = 0; j < i; j++)
- {
- Console.SetCursorPosition(x, y++);
- Console.Write("*");
- if (j == i - 1 && id[0]==false )
- {
- Console.CursorLeft = 0;
- for (j = 0; j < 2 * i - 1; j++)
- Console.Write("*");
- x = Console.CursorLeft - 1;
- y = Console.CursorTop;
- j = -1;
- id[1] = !(id[0]=true);
- }
- if (id[0] == true&&id[1]==false )
- {
- id[1] = true;
- continue;
- }
- }
- x = 2 * i - 1;
- y = 3;
- int left;
- id[1] = !(id[0]=false);
- for (int j = 0; j < i; j++)
- {
- Console.SetCursorPosition(--x, y);
- Console.Write("*");
- left=Console.CursorLeft-1;
- if(j==i-1 && id[0]==false)
- {
- Console.CursorLeft--;
- for (j = 0; j < 2 * i - 1; j++)
- {
- Console.SetCursorPosition(left, j + 3);
- Console.Write("*");
- }
- j = 0;
- id[1] = !(id[0]=true);
- }
- if (id[0] == true&&id[1]==false )
- {
- y = Console.CursorTop;
- continue;
- }
- }
- Console.CursorTop = 3 + 2 * i - 1;
- Console.WriteLine();
- }
- else
- {
- Console.WriteLine("Please enter a valid number...");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement