Sinceramente me cuesta demasiado pascal. y tengo que rendir un final en unas horas y no encuentro ningun ejercicio completo y sin errores que me pueda ayudar.
El ejercicio que tengo como modelo de final es el siguiente:
Desarrollar un programa en pascal que permita crear y cargar un archivo de alumos para llevar un control de las notas de sus examenes parcials de la asignatura programacion 1. La estructura de los registros sera la siguiente:Nro_DNI, Apellido, Nombre, NP1, NP2:
a) Mediante un procedimiento, al que debera llamar ListadoAprobados, mostrar por pantalla el listado de los alumnos que hayan regularizado la materia, para ello, el promedio de ambas notas dbera ser igual o mayor a 7.
b) Permitir, al usuario realizar la busqueda de alumnos ingresando el numero de DNI. Mostrar los datos encontrados, en caso contrario, el siguiente mensaje "No se encuentran datos del Alumno".
Muy importante. Todo esto se graba en un archivo de datos que despues se lee. Creo que se hacia con un archivo.dat pero no me acuerdo.
Necesito ayuda urgente, por favor...
Desde ya muchas gracias
Facundo
Así es difícil ayudarte, deberías dar la estructura del registro por lo menos, o el rango de notas en los parciales, es decir con 7 apruebas, pero ¿cuánto es lo mínimo y máximo que puedes sacarte?, supongo que el DNI es una identificación ¿cuál es el máximo de dígitos?
Lo de exportar los datos creo que sería mejor usar una gran estructura donde guardarlos y cargarlos desde cmd:
type datos.txt | programa.exe > salida.txt
No dices si tienes permitido usar facilidades del compilador como USES, string, etc. o debes usar arreglos con tope para guardar los nombres.
El rango de notas es entre 1 y 10.
EL DNI es un numero de identificacion que tiene 8 numeros asi 12345678.
Lo otro nose como respondertelo sinceramente...
Encontre un ejemplo parecido pero que involucra pasar datos de binario a texto y no creo que es lo que me pidan...Mira..
{A ver si esto ayuda}
program archivos;
uses
crt;
type
regdatos = record
nombre : string[80];
cedula : longint;
notas : array[1..3] of real;
end;
var
f : file of regdatos;
dato : array[1..10] of regdatos;
tex : text;
medias : array[1..10] of real;
nom : array[1..10] of string[80];
procedure entradatos;
var
h, cont : integer;
tec : char;
begin
cont := 1;
repeat
clrscr;
write(' Entre Nombre : ');
readln(dato[cont].nombre);
write(' Entre Cedula : ');
readln(dato[cont].cedula);
write(' Entre notas 1 : ');
readln(dato[cont].notas[1]);
write(' Entre notas 2 : ');
readln(dato[cont].notas[2]);
writeln;
writeln(' Dese entrar mas datos [S/N] ');
repeat
tec := upcase(readkey);
until tec in ['S','N'];
if tec = 'N' then
tec := #27
else
cont := cont + 1;
until (cont > 10) or (tec = #27);
assign(f,'Temporal.dat');
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
rewrite(f);
h := 0;
repeat
seek(f,h);
write(f,dato[h + 1]);
h := h + 1;
until h > cont;
close(f);
end
else
begin
writeln(' El archivo existe desea Anularlo por este [S/N] ');
repeat
tec := upcase(readkey);
until tec in['S','N'];
if tec in['N'] then
begin
end
else
begin
rewrite(f);
h := 0;
repeat
seek(f,h);
write(f,dato[h + 1]);
h := h + 1;
until h > cont;
close(f);
end;
end;
end;
procedure pasaloatexto;
var
i, g : longint;
begin
assign(f,'Temporal.dat');
{$I-} reset(f); {$I+}
if ioresult <> 0 then
begin
writeln(' El Archivo No Existe Pulse [Enter] ');
readln;
exit;
end
else
begin
assign(tex,'temporal.txt');
rewrite(tex);
for i := 0 to filesize(f) - 2 do
begin
seek(f,i);
read(f,dato[i + 1]);
writeln(tex,dato[i + 1].nombre);
writeln(tex,dato[i + 1].cedula);
writeln(tex,dato[i + 1].notas[1]:3:2);
writeln(tex,dato[i + 1].notas[2]:3:2);
end;
close(f);
close(tex);
writeln('Archivo De Binario A Texto');
end;
end;
procedure sacamedia;
var
p, i : integer;
nomb : string[80];
cod : longint;
n1, n2 : real;
begin
assign(tex,'temporal.txt');
{$I-} reset(tex); {$I+}
if ioresult <> 0 then
begin
writeln(' Error El Archivo No Existe Pulse [Enter]');
readln;
exit;
end
else
begin
p := 1;
while not eof(tex) do
begin
read(tex,nomb);
read(tex,cod);
read(tex,n1);
read(tex,n2);
readln(tex);
nom[p] := nomb;
medias[p] := (n1 + n2) / 2;
writeln(nom[p],' La Media Es = ',medias[p]:3:2);
p := p + 1;
if p > 10 then
p := 10;
end;
close(tex);
end;
end;
procedure menu;
var
te : char;
begin
repeat
clrscr;
writeln('****** Menu General ******');
writeln;
writeln(' 1 = Entrada De Datos');
writeln(' 2 = Archivo Binario A Texto');
writeln(' 3 = Presenta Las Medias');
writeln(' 4 = Salir');
writeln;
writeln('<<<<< Elija Opcion >>>>>');
repeat
te := readkey;
until te in[#49,#50,#51,#52];
case te of
#49 : begin clrscr; entradatos; end;
#50 : begin clrscr; pasaloatexto; writeln(' Pulse [Enter]'); readln; end;
#51 : begin clrscr; sacamedia; readln; end;
end;
until te = #52;
end;
begin
menu;
end.
Me respondieron en otro foro....Pongo la solucion para alguien que busque en google y no encuentre nada como me paso ami...
Gracias...supongo....
PD: Cierren el post y pongan como solucionado.
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.