Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Mensajes - kofu

Páginas: [1]
1
Aprender a programar desde cero / SOLUCION
« en: 20 de Diciembre 2015, 23:55 »
Me respondieron en otro foro y pongo la respuesta aca....
Asi que gracias...supongo...

CIERREN EL POST Y MARQUENLO COMO SOLUCIONADO.


Código: [Seleccionar]
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.

2
La verdad que no me sirvio...ENcontre un ejemplo que es mas edecuado al mio..Pero me faltan modificar unas cosas...Me podrias ayudar por favor?

{A ver si esto ayuda}
 
Código: [Seleccionar]
  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.

3
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

Páginas: [1]

Sobre la educación, sólo puedo decir que es el tema más importante en el que nosotros, como pueblo, debemos involucrarnos.

Abraham Lincoln (1808-1865) Presidente estadounidense.

aprenderaprogramar.com: Desde 2006 comprometidos con la didáctica y divulgación de la programación

Preguntas y respuestas

¿Cómo establecer o cambiar la imagen asociada (avatar) de usuario?
  1. Inicia sesión con tu nombre de usuario y contraseña.
  2. Pulsa en perfil --> perfil del foro
  3. Elige la imagen personalizada que quieras usar. Puedes escogerla de una galería de imágenes o subirla desde tu ordenador.
  4. En la parte final de la página pulsa el botón "cambiar perfil".