Skip to content

Instantly share code, notes, and snippets.

@d630
Last active June 6, 2018 15:44
Show Gist options
  • Save d630/c881121354e75b3ab7090b2a0518f22c to your computer and use it in GitHub Desktop.
Save d630/c881121354e75b3ab7090b2a0518f22c to your computer and use it in GitHub Desktop.
Pyramide
using System;
namespace csharp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Number: ");
int i, j, k;
//int n = Convert.ToInt16(Console.ReadLine());
int n = int.Parse(Console.ReadLine());
for (i = 0; i < n; i++)
{
for (j = 0; j < n - i; j++)
Console.Write(" ");
for (k = 0; k < 2 * i + 1; k++)
Console.Write("x");
Console.WriteLine();
}
}
}
}
@d630
Copy link
Author

d630 commented Jun 5, 2018

#/usr/bin/env bash

read -r -p "Number: " n;

printf -v r %$((2 * n + 1))c;

for ((i=0; i < n; i++))
do
	rr=${r:1:$((2 * i + 1))};
	printf "%$((n - i))c%s\n"  ' ' ${rr// /x};
done

# vim: set ft=sh :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment