Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
practica 7 ejercicio B5
program HelloWorld; {-----------------------------------------------------------------------------------------------------------------------} {----------------------------------------------------------------- CONST - Define las constantes para usar en tiempo de compilacion} const DimC = 10; DimF = 10; {-----------------------------------------------------------------------------------------------------------------------} {-----------------------------------------------------------------------------------------------------------------------} {----------------------------------------------------------------- TYPE - Define los tipos creados por el usuario para usar en tiempo de compilacion} type rangoFila = 1 .. DimF; rangoColumna = 1 .. DimC; Tmatriz = record matriz : array [rangoFila, rangoColumna] of integer; DimLF : rangoFila; DimLC : rangoColumna; end; {-----------------------------------------------------------------------------------------------------------------------} {-----------------------------------------------------------------------------------------------------------------------} {----------------------------------------------------------------- VARIABLES GLOBALES - Define variables que se podran usar por todos los modulos de ser necesarias} //var {-----------------------------------------------------------------------------------------------------------------------} {-----------------------------------------------------------------------------------------------------------------------} {----------------------------------------------------------------- CARGAR MATRIZ} procedure cargarMatriz(var m : Tmatriz); var i:rangoFila; j:rangoColumna; begin randomize; for i:= 1 to DimF do for j:=1 to DimC do m.matriz[i,j]:=random(100); end; {----------------------------------------------------------------- IMPRIMIR LINEA} procedure imprimirLinea(); var j:rangoColumna; begin write(' '); for j := 1 to DimC do write('-----'); writeln; end; {----------------------------------------------------------------- IMPRIMIR} procedure imprimir( n : integer); begin if n > 9 then begin write(n); end else write('0',n); end; {----------------------------------------------------------------- IMPRIMIR 2} procedure imprimir2( n : integer); begin if n > 9 then begin writeln(' | ',n,' |'); end else writeln(' | 0',n,' |'); end; {----------------------------------------------------------------- IMPRIMIR COLUMNAS} procedure imprimirColumnas(); var j : rangoColumna; begin writeln; write(' '); for j:=1 to DimC do if j > 9 then begin write(' ',j); end else write(' 0',j); writeln; end; {----------------------------------------------------------------- IMPRIMIR MATRIZ} procedure imprimirMatriz(m : Tmatriz); var i : rangoFila; j : rangoColumna; h:integer; begin imprimirColumnas(); imprimirLinea(); for i := 1 to DimF do begin h:=i; imprimir(h); for j := 1 to DimC-1 do begin write(' | '); imprimir(m.matriz[i,j]); end; imprimir2(m.matriz[i,DimC]); imprimirLinea(); end; end; {----------------------------------------------------------------- IMPRIMIRR FILAS PARES} procedure imprimirFilasPares(m : Tmatriz); var i : rangoFila; j : rangoColumna; h:integer; begin imprimirColumnas(); imprimirLinea(); for i := 1 to DimF do begin h:=i; imprimir(h); for j := 1 to DimC-1 do begin if h mod 2 = 0 then begin write(' | '); imprimir(m.matriz[i,j]); end; end; if h mod 2 = 0 then begin imprimir2(m.matriz[i,DimC]); end else writeln; imprimirLinea(); end; end; {----------------------------------------------------------------- IMPRIMIR COLUMNAS IMPARES} procedure imprimirColumnasImpares(m : Tmatriz); var i : rangoFila; j : rangoColumna; h:integer; begin imprimirColumnas(); imprimirLinea(); for i := 1 to DimF do begin h:=i; imprimir(h); for j := 1 to DimC-1 do begin if j mod 2 <> 0 then begin write(' | '); imprimir(m.matriz[i,j]); end else write(' | '); end; if DimC mod 2 <> 0 then begin imprimir2(m.matriz[i,DimC]); end else writeln(' | |'); imprimirLinea(); end; end; {----------------------------------------------------------------- IMPRIMIR DIAGONAL} procedure imprimirDiagonal(m : Tmatriz); var i : rangoFila; j : rangoColumna; h:integer; begin imprimirColumnas(); imprimirLinea(); for i := 1 to DimF do begin h:=i; imprimir(h); for j := 1 to DimC-1 do begin if j = i then begin write(' | '); imprimir(m.matriz[i,j]); end else write(' | '); end; if DimC = i then begin imprimir2(m.matriz[i,DimC]); end else writeln(' | |'); imprimirLinea(); end; end; {-----------------------------------------------------------------------------------------------------------------------} {-----------------------------------------------------------------------------------------------------------------------} {----------------------------------------------------------------- PROGRAMA PRINCIPAL} var m: Tmatriz; begin cargarMatriz(m); imprimirMatriz(m); imprimirFilasPares(m); imprimirColumnasImpares(m); imprimirDiagonal(m); end. {-----------------------------------------------------------------------------------------------------------------------}
run
|
edit
|
history
|
help
0
Zad 3 a
Squarepants
yghgh
135
NOT a String in Pascal
TAIRINE GOMES NEPOUMUCENO 600624521
Project Euler 18 - Maximum path sum
test01
BIANCA SAMPAIO ALFRADIQUE 600615759
Урок 3 задача 3