Ver Mensaje Individual
  #10 (permalink)  
Antiguo 20/12/2015, 16:49
kofu92
 
Fecha de Ingreso: diciembre-2015
Ubicación: Formosa
Mensajes: 6
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Ejercicio de Archivos PASCAL

Ya que nadie me ayudó y solo me trataron de explicar asi no mas pongo la solucion que la pedi en otro foro y fueron amables en responderme bien...
Nos vemos
gracias..supongo...



program alumnos;
uses
crt;
const
archivo = 'archivo.dat';
type
elalumnos = record
Nro_DNI : longint;
Apellido : string[80];
Nombre : string[80];
NP1,NP2 : real;
end;

var
f : file of elalumnos;
alum : elalumnos;



function existearchivo : boolean;
begin
assign(f,archivo);
{$I-} reset(f); {$I+}
if ioresult <> 0 then
existearchivo := false
else
begin
existearchivo := true;
end;
end;

procedure entradadatos;
var
tec : char;
begin
clrscr;
writeln(' ****** Entrada Datos Alumno Nuevo ******');
writeln;
write(' Ingrese el DNI (Sin Puntos) : ');
readln(alum.Nro_DNI);
write(' Ingrese Apellido : ');
readln(alum.Apellido);
write(' Ingrese Nombre : ');
readln(alum.Nombre);
write(' Ingrese Nota 1 : ');
readln(alum.NP1);
write(' Ingrese Nota 2 : ');
readln(alum.NP2);
writeln;
writeln(' Se Guardar Los Datos ');
writeln;
writeln(' Datos Correctos [S/N]');
repeat
tec := upcase(readkey);
until tec in['S','N'];
if tec = 'S' then
begin
if existearchivo = true then
begin
seek(f,filesize(f));
write(f,alum);
close(f);
end
else
begin
rewrite(f);
seek(f,0);
write(f,alum);
close(f);
end;
end;
end;

procedure ListadoAprobados;
var
k : longint;
begin
if existearchivo = true then
begin
writeln(' Los Aprobados Son: ');
writeln;
for k := 0 to filesize(f) - 1 do
begin
seek(f,k);
read(f,alum);
if ((alum.np1 + alum.np2) / 2) >= 7 then
writeln(' Aprobado : ',alum.nombre,' ',alum.apellido,' ',
((alum.np1 + alum.np2) / 2):0:2);
end;
close(f);
readkey;
end
else
begin
writeln(' No se encuentran datos del Alumno [Pulse Una Tecla]');
readkey;
end;
end;

procedure busqueda_alumno;
var
ddn : longint;
vus : longint;
encon : boolean;
begin
if existearchivo = true then
begin
writeln(' Buscar Un Alumno ');
writeln;
write(' Ingrese el DNI : ');
readln(ddn);
encon := false;
for vus := 0 to filesize(f) - 1 do
begin
seek(f,vus);
read(f,alum);
if alum.Nro_DNI = ddn then
begin
encon := true;
break;
end;
end;
if encon = true then
writeln('DNI: ',alum.Nro_DNI,' Nombre: ',alum.nombre,' ',alum.apellido,' Nota 1: ',
alum.np1:0:2,' Nota 2: ',alum.np2:0:2,' Promedio = ',
((alum.np1 + alum.np2) / 2):0:2)
else
writeln(' No se encuentran datos del Alumno ');
close(f);
writeln;
writeln(' [Pulse Una Tecla]');
readkey;
end
else
begin
writeln(' No se encuentran datos del Alumno [Pulse Una Tecla]');
readkey;
end;
end;


procedure menu;
var
sal : boolean;
tecla : char;
begin
sal := false;
repeat
clrscr;
writeln(' ***** Menu General *****');
writeln;
writeln(' 1 = Ingreseo de Alumno');
writeln(' 2 = Ver Aprobados');
writeln(' 3 = Mostrar Un Alumno');
writeln(' 4 = Salir');
writeln;
writeln(' >>> Elija Opcion <<<');
repeat
tecla := readkey;
until tecla in['1','2','3','4'];
clrscr;
case tecla of
'1' : entradadatos;
'2' : ListadoAprobados;
'3' : busqueda_alumno;
'4' : sal := true;
end;
until sal = true;
end;




begin
menu;
end.