Task: Draw a cuboid








VB: x = 6 : y = 2 : z = 3

Sub cuboid(nx, ny, nz)
   WScript.StdOut.WriteLine "Cuboid " & nx & " " & ny & " " & nz & ":"
   lx = X * nx : ly = y * ny : lz = z * nz

   
   Dim area(): ReDim area(ly+lz, lx+ly)
   For i = 0 to ly+lz
      For j = 0 to lx+ly : area(i,j) = " " : Next
   Next

   
   For i = 0 to nz-1 : drawLine area, lx,      0,    Z*i, "-" : Next
   For i = 0 to ny   : drawLine area, lx,    y*i, lz+y*i, "-" : Next
   For i = 0 to nx-1 : drawLine area, lz,    x*i,      0, "|" : Next
   For i = 0 to ny   : drawLine area, lz, lx+y*i,    y*i, "|" : Next
   For i = 0 to nz-1 : drawLine area, ly,     lx,    z*i, "/" : Next
   For i = 0 to nx   : drawLine area, ly,    x*i,     lz, "/" : Next

   
   For i = UBound(area,1) to 0 Step -1
      linOut = ""
      For j = 0 to UBound(area,2) : linOut = linOut & area(i,j) : Next
      WScript.StdOut.WriteLine linOut
   Next
End Sub

Sub drawLine(arr, n, sx, sy, c)
   Select Case c
      Case "-"
         dx = 1 : dy = 0
      Case "|"
         dx = 0 : dy = 1
      Case "/"
         dx = 1 : dy = 1
   End Select
   For i = 0 to n
      xi = sx + (i * dx) : yi = sy + (i * dy)
      If arr(yi, xi) = " " Then
         arr(yi, xi) = c
      Else
         arr(yi, xi) = "+"
      End If
   Next
End Sub

cuboid 2,3,4




Ada: with Ada.Text_IO;

procedure Main is
   type Char_Matrix is
     array (Positive range <>, Positive range <>) of Character;

   function Create_Cuboid
     (Width, Height, Depth : Positive)
      return                 Char_Matrix
   is
      Result : Char_Matrix (1 .. Height + Depth + 3,
         1 .. 2 * Width + Depth + 3) := (others => (others => ' '));
   begin
      
      Result (1, 1)                                      := '+';
      Result (Height + 2, 1)                             := '+';
      Result (1, 2 * Width + 2)                          := '+';
      Result (Height + 2, 2 * Width + 2)                 := '+';
      Result (Height + Depth + 3, Depth + 2)             := '+';
      Result (Depth + 2, 2 * Width + Depth + 3)          := '+';
      Result (Height + Depth + 3, 2 * Width + Depth + 3) := '+';
      
      for I in 1 .. 2 * Width loop
         Result (1, I + 1)                          := '-';
         Result (Height + 2, I + 1)                 := '-';
         Result (Height + Depth + 3, Depth + I + 2) := '-';
      end loop;
      
      for I in 1 .. Height loop
         Result (I + 1, 1)                             := '|';
         Result (I + 1, 2 * Width + 2)                 := '|';
         Result (Depth + I + 2, 2 * Width + Depth + 3) := '|';
      end loop;
      
      for I in 1 .. Depth loop
         Result (Height + 2 + I, 1 + I)             := '/';
         Result (1 + I, 2 * Width + 2 + I)          := '/';
         Result (Height + 2 + I, 2 * Width + 2 + I) := '/';
      end loop;
      return Result;
   end Create_Cuboid;

   procedure Print_Cuboid (Width, Height, Depth : Positive) is
      Cuboid : Char_Matrix := Create_Cuboid (Width, Height, Depth);
   begin
      for Row in reverse Cuboid'Range (1) loop
         for Col in Cuboid'Range (2) loop
            Ada.Text_IO.Put (Cuboid (Row, Col));
         end loop;
         Ada.Text_IO.New_Line;
      end loop;
   end Print_Cuboid;
begin
   Print_Cuboid (2, 3, 4);
end Main;