7 matriz = array[1..max, 1..max] of integer;
\r
9 (***********************************************************************)
\r
11 function GetPrimo( n: integer ): integer;
\r
22 for i:= 2 to trunc( sqrt( n ) ) + 1 do
\r
23 if ( n mod i ) = 0 then primo := false;
\r
24 if not primo then n := n + 1;
\r
30 (***********************************************************************)
\r
32 procedure CargaMatriz( var mat: matriz; tope: integer );
\r
35 prim, i, j: integer;
\r
39 for i := 1 to tope do
\r
40 for j := 1 to tope do
\r
42 mat[i,j] := GetPrimo( prim + 1 );
\r
47 (***********************************************************************)
\r
49 procedure MuestraMatriz( var mat: matriz; tope: integer);
\r
55 for i := 1 to tope do
\r
57 for j := 1 to tope do
\r
58 write( mat[i,j] : 7 );
\r
63 (***********************************************************************)
\r
65 procedure RecorreMatriz( var mat: matriz; mn, mx: integer );
\r
67 procedure RecMat( var mat: matriz; mn, mx: integer );
\r
75 for j := mn to mx do
\r
76 write( mat[mn,j] : 1, ', ' );
\r
77 for i := mn + 1 to mx do
\r
78 write( mat[i,mx] : 1, ', ' );
\r
79 for j := mx - 1 downto mn do
\r
80 write( mat[mx,j] : 1, ', ' );
\r
81 for i := mx - 1 downto mn + 1 do
\r
82 write( mat[i,mn] : 1, ', ' );
\r
83 RecMat( mat, mn + 1, mx - 1 );
\r
88 RecMat( mat, mn, mx );
\r
92 (***********************************************************************)
\r
99 write( 'Ingrese un n£mero (', max : 1, ' m ximo): ' );
\r
103 writeln( 'El n£mero que ingres¢ es muy grande, el m ximo es ', max : 1 );
\r
104 write( ' Ingrese otro n£mero: ' );
\r
108 writeln( ' Cargando Matriz...' );
\r
110 CargaMatriz( mat, n );
\r
111 { MuestraMatriz( mat, n ); }
\r
113 writeln( ' Matriz cargada.' );
\r
115 RecorreMatriz( mat, 1, n );
\r