Skip to content

Instantly share code, notes, and snippets.

@bigworld12
Created December 30, 2016 19:29
Show Gist options
  • Save bigworld12/89c034271b5edc44eab09244bc6d3236 to your computer and use it in GitHub Desktop.
Save bigworld12/89c034271b5edc44eab09244bc6d3236 to your computer and use it in GitHub Desktop.
Console.WriteLine("Please enter lines count : ");
int lines = int.Parse(Console.ReadLine());
//line count = 5
//4 spaces, i = 1,last number = 1
//3 spaces, i = 2,last number = 3
//2 spaces, i = 3,last number = 5
//1 space, i = 4,last number = 7
//0 space, i = 5,last number = 9
for (int i = 1; i <= lines; i++)
{
int spaces = lines - i;
int last_number = i * 2 - 1;
for (int s = 1; s <= spaces * 2 ; s++)
{
Console.Write(" ");
}
for (int j = 1; j <= last_number; j++)
{
Console.Write(j);
Console.Write(" ");
}
Console.WriteLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment