From dcda6a19551630ed5b1f5318e05b59e98b9a568c Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Tue, 6 Apr 2021 17:48:16 +0200 Subject: [PATCH] Solving some issues commented by the students. --- ejercicio2.pas | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/ejercicio2.pas b/ejercicio2.pas index e983c23..7ed5815 100644 --- a/ejercicio2.pas +++ b/ejercicio2.pas @@ -1,4 +1,4 @@ -uses sysutils; +uses sysutils,crt; type CostoArrayRow = array[1..3] of double; @@ -16,16 +16,16 @@ var i, j: Int64; begin for i := 1 to Length(ESTACIONES) do - write(#9 + ESTACIONES[i]); + write(' ' + ESTACIONES[i]); write(#10); for i := 1 to Length(cantidad) do begin write(ARTICULOS[i]); for j := 1 to Length(cantidad[i]) do begin - write(#9 + IntToStr(cantidad[i][j])); + write(' ' + IntToStr(cantidad[i][j])); end; - write(#10); + writeln(''); end; end; @@ -34,16 +34,16 @@ var i, j: Int64; begin for i := 1 to Length(ARTICULOS) do - write(#9 + ARTICULOS[i]); - write(#10); + write(' ' + ARTICULOS[i]); + writeln(''); for i := 1 to Length(costo) do begin write(COSTES[i]); for j := 1 to Length(costo[i]) do begin - write(#9 + FloatToStr(costo[i][j])); + write(' ' + FloatToStr(costo[i][j])); end; - write(#10); + writeln(''); end; end; @@ -53,8 +53,8 @@ var precio_por_cantidad: double; begin for i := 1 to Length(ESTACIONES) do - write(#9 + ESTACIONES[i]); - write(#10); + write(' ' + ESTACIONES[i]); + writeln(''); for i := 1 to Length(COSTES) do begin @@ -63,18 +63,21 @@ begin begin precio_por_cantidad := 0; for k := 1 to Length(ARTICULOS) do - precio_por_cantidad += cantidad[k][j] * costo[j][k]; - write(#9 + FloatToStr(precio_por_cantidad)); + precio_por_cantidad += cantidad[k][j] * costo[i][k]; + write(' ' + FloatToStr(precio_por_cantidad)); end; - write(#10); + writeln(''); end; end; procedure printTables(costo: CostoArray; cantidad: CantidadArray); begin printCosto(costo); + writeln(''); printCantidad(cantidad); + writeln(''); printCostoPorEstacion(costo, cantidad); + writeln(''); end; var @@ -83,6 +86,7 @@ var i, j: Int64; begin + ClrScr; Randomize; for i := 1 to 3 do @@ -95,4 +99,5 @@ begin cantidad[i][j] := Random(2000) + 500; printTables(costo, cantidad); + ReadKey; end.