This is the first reverse pyramid
like
for ( i= 10; i >= 1; --i)
{
for (j = 1; j <= i; j)
{
Console.Write(j i);
}
Console.WriteLine();
}
For the second one, I want the pyramid reversed, but this time it needs to be a mirror image of the first one, and I also want it to start at the same line where the first one ended, I want it to look like an arch.
can anyone help me
output i want something like this
CodePudding user response:
This works for me:
var output =
String.Join(
Environment.NewLine,
from i in Enumerable.Range(0, 10).Select(x => 10 - x)
let ns = Enumerable.Range(1, i).Select(x => x i)
select $"{String.Concat(ns).PadRight(20)}{String.Concat(ns.Reverse()).PadLeft(20)}");
Console.WriteLine(output);
I get this output:
1112131415161718192020191817161514131211
101112131415161718 181716151413121110
910111213141516 161514131211109
891011121314 141312111098
789101112 121110987
678910 109876
5678 8765
456 654
34 43
2 2