Last active
June 6, 2018 15:44
-
-
Save d630/c881121354e75b3ab7090b2a0518f22c to your computer and use it in GitHub Desktop.
Pyramide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| } | |
| } | |
| } | |
| } |
#/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
Uh oh!
There was an error while loading. Please reload this page.