PROGRAM E_j_d_l_V; Uses crt; {Variables del programa principal} Var option, celdas: integer; mundo: string; {Funci¢n para el Men£ principal} Function Menu:integer; Begin Writeln ('***MENé PRINCIPAL***'); Writeln; Repeat Writeln ('Elija una de las siguientes opciones: '); Writeln; Writeln ('1 * Generar mundo aleatorio'); Writeln ('2 * Ejecuci¢n'); Writeln ('3 * Cargar Estado Inicial'); Writeln ('4 * Salir'); {$I-} Readln (option); Until (ioresult=0) and (option>0) and (option<5); {$I+} Menu:= option; End; {Funci¢n para la primera opci¢n del Men£ pricipal (Generar mundo aleatorio)} Function cargar_mundo (cm: string): string; Var fichero: text; linea: string; mundo: string[200]; Begin assign (fichero, cm); Reset (fichero); mundo:= ''; while not eof(fichero) do begin Readln(fichero,linea); mundo:=mundo+linea+'|'; end; cargar_mundo:=mundo; End; {Creaci¢n del Tablero} Type TTable = ARRAY [1..20,1..20] OF integer; Procedure Tablero (cas: integer); Var a, b, c, d : integer; Tab : TTable; Begin Randomize; clrscr; gotoXY (1,1); For a:= 1 to cas do begin For b:= 1 to cas do c:= random(4); If (c = 0) then begin Tab [a,b]:= 1; end else begin Tab [a,b]:= 0; end; end; For d:= 1 to cas do Tab [1, d]:= 0; Tab [cas,d]:= 0; Tab [d, 1]:= 0; Tab [d, cas]:= 0; End; {Inicio del programa principal (Cuerpo del programa principal)} BEGIN clrscr; textcolor (18); writeln (' *****************************************'); normvideo; textcolor (19); writeln (' ***********El Juego de la Vida***********'); normvideo; textcolor (18); writeln (' *****************************************'); writeln; normvideo; writeln ('Empecemos definiendo el tablero, introduzca un valor desde 4 a 20 para definir '); writeln ('el n£mero de celdas por lado que desea que tenga el tablero: '); readln (celdas); While not (celdas >=4) and (celdas <=20) do Repeat writeln ('Ha introducido un valor que no corresponde, recuerda, ha de ser entre 4 y 20: '); {$I-} Readln (celdas); Until (ioresult = 0) and (celdas >= 4) and (celdas <= 20); {$I+} {Llamada a la funci¢n cargar_mundo} mundo:= cargar_mundo('mundo.txt'); writeln(mundo); writeln(mundo[8]); writeln(mundo[25]); END. ---------------------------- (añadido tras someter) ---------------------------- 19:27:21 11/12/09 -> Segun los datos introducidos los ficheros son: G01P07D2 -> Los autores del trabajo son: Lozano Ariza, Alberto Nombres originales de los archivos entregados -> J_d_l_V.PAS, J_d_l_V.txt