Water collected between towers: Difference between revisions

→‎{{header|C sharp|C#}}: added using dependencies, modified code to show towers upright instead of upside-down. Changed characters to match REXX 9.3 output when showing tower blocks.
(Added C# program, translation of vb.NET)
(→‎{{header|C sharp|C#}}: added using dependencies, modified code to show towers upright instead of upside-down. Changed characters to match REXX 9.3 output when showing tower blocks.)
Line 306:
=={{header|C sharp|C#}}==
Translation from [[{{FULLPAGENAME}}#Visual_Basic_.NET|Visual Basic .NET]]. See that entry for code comments and details.
<lang Csharp>using System;</lang>
<lang Csharp>static void Main(string[] args)
{
Line 315 ⟶ 316:
string blk = "", lf = "\n"; for (int i = 0; i < wta.Length; i++)
{
int bpl = -1bpf; blk = ""; do
{
bplstring floor = ""; bpf = 0; for (int j = 0; j < wta[i].Length; j++)
{
if (wta[i][j] > 0)
{ blkfloor += "B"'█'; wta[i][j] -= 1; bplbpf += 1; }
else blkfloor += (j > 0 && j < wta[i].Length - 1 ? "."'≈' : "' "');
}
if (bplbpf > 0) blk += floor + lf + blk;
} while (bplbpf > 0);
while (blk.Contains(" .")) blk = blk.Replace(" .", " ");
while (blk.Contains(". ")) blk = blk.Replace(". ", " ");
if (args.Length > 0) Console.WriteLineWrite(lf +"{0}", blk);
Console.WriteLine("Block {0} retains {1,2} water units.\n", i + 1,
(blk.Replace(lf, "").Replace("B", "").Replace(" ", "")).Length);
}