Pascal/Turbo Pascal - Ayuda Ejercicio en Pascal

 
Vista:

Ayuda Ejercicio en Pascal

Publicado por Andrea Jimenez (1 intervención) el 20/04/2016 06:20:16
¡Hola chicos que tal como les va! si pudiesen ayudarme con este ejercicio de programación se los agradecería mucho!
Es para realizar en pascal: un maestro tiene 30 alumnos y cada aprendiz tiene 3 calificaciones en el primer parcial. Almacenar los datos en un archivo, dejando espacio para dos notas más y la nota final. Incluir un menú de opciones para añadir más aprendices, visualizar datos de un aprendiz, introducir nuevas notas y calcular nota final.
Se pide:
1) Crear un archivo sin formato (binario) para almacenar cada registro.
2) En la opción: MOSTRAR TODO (deberá mostrar todos los registros), los datos deberán mostrarse ordenados alfabéticamente por apellido en forma ascendente
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Ayuda Ejercicio en Pascal

Publicado por ramon (2158 intervenciones) el 20/04/2016 19:02:28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
{A ver si esto te ayuda }
 
program registros;
  uses
     crt;
   type
     string80 = string[80];
     alumno = record
          nombre : string80;
          apellido : string80;
          parcial : integer;
          notas : array[1..5] of real;
          con :  integer;
          notafinal : real;
         end;
  const
     alum = 'alumnos.dat';
 
  var
    f : file of alumno;
    dato : alumno;
    cont : integer;
 
  procedure guardanotas(n : alumno);
  begin
     assign(f,alum);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
        rewrite(f);
        seek(f,0);
        write(f,n);
        close(f);
    end
  else
     begin
        seek(f,filesize(f));
        write(f,n);
        close(f);
     end;
  end;
 
  procedure entrada_datos(var a : alumno);
  begin
     clrscr;
     writeln('   Entrada Datos Y Notas Alumno');
     writeln;
     write('   Entre Nombre   = ');
     readln(a.nombre);
     write('   Entre Apellido = ');
     readln(a.apellido);
     write('   Entre Parcial  = ');
     readln(a.parcial);
     write('   Entre Nota  1  = ');
     readln(a.notas[1]);
     write('   Entre Nota  2  = ');
     readln(a.notas[2]);
     write('   Entre Nota  3  = ');
     readln(a.notas[3]);
     a.con := 3;
     a.notafinal := 0;
     guardanotas(a);
  end;
 
  procedure presenta_alumnos;
  var
     regtemp : array[1..30] of alumno;
     temp : alumno;
     p, n, k : integer;
     t : longint;
  begin
     assign(f,alum);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('   Error De Archivo O No Existe Pulse Una Tecla');
       readkey;
    end
  else
     begin
        p := 1;
        for t := 0 to filesize(f) - 1 do
        begin
          seek(f,t);
          read(f,dato);
          regtemp[p] := dato;
          p := p + 1;
        end;
        close(f);
        for n := 1 to p - 1 do
          for k := p - 1 downto n + 1 do
          if regtemp[n].apellido > regtemp[k].apellido then
          begin
             temp := regtemp[n];
             regtemp[n] := regtemp[k];
             regtemp[k] := temp;
          end;
         clrscr;
         write(' Nombre      Apellido    Parcial  Notas : ');
         for k := 1 to 5 do
         write(' ',k,'   ');
         write('  Final');
         writeln;
         writeln;
         for n := 1 to p - 1 do
    writeln(' ',regtemp[n].nombre,'       ',regtemp[n].apellido,'          ',
         regtemp[n].parcial,'            ',regtemp[n].notas[1]:0:2,' ',
         regtemp[n].notas[2]:0:2,' ',regtemp[n].notas[3]:0:2,' ',
         regtemp[n].notas[4]:0:2,' ',regtemp[n].notas[5]:0:2,'    ',
         regtemp[n].notafinal:0:2);
         readkey;
     end;
  end;
 
  procedure pasa_amayus(var p : string80);
  var
    j : integer;
    begin
      for j := 1 to length(p) do
      p[j] := upcase(p[j]);
    end;
 
  procedure nuevasnotas;
  var
    eln, eap, nom, ape : string80;
    pos, h : longint;
    esta : boolean;
    no, i : integer;
  begin
      clrscr;
      writeln('   Entrada Nuevas Notas ');
      writeln;
      write('  Entre Nombre   : ');
      readln(nom);
      write('  Entre Apellido : ');
      readln(ape);
      pasa_amayus(nom);
      pasa_amayus(ape);
      assign(f,alum);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('   Error De Archivo O No Existe Pulse Una Tecla');
       readkey;
    end
  else
     begin
         esta := false;
         pos := -0;
         for h := 0 to filesize(f) - 1 do
         begin
            seek(f,h);
            read(f,dato);
            eln := dato.nombre;
            eap := dato.apellido;
            pasa_amayus(eln);
            pasa_amayus(eap);
            if ( eln = nom) and ( eap = ape) then
            begin
               pos := h;
               esta := true;
               break;
            end;
         end;
          if esta = true then
          begin
            no := dato.con;
            if no < 5 then
            begin
            for i := no + 1 to 5 do
            begin
            write('  Entre Nota N. ',i,' : ');
            readln(dato.notas[i]);
            dato.con := dato.con + 1;
            end;
              seek(f,pos);
              write(f,dato);
              close(f);
            end
          else
             begin
               writeln('   Notas Completadas Pulse Una Tecla ');
               readkey;
               close(f);
             end;
          end
       else
          begin
             writeln('  Nombre Y Apellido No Encontrados Pulse Una Tecla');
             readkey;
             close(f);
          end;
     end;
   end;
 
  procedure notafinal;
  var
     nom, ape : string80;
     h, p : longint;
     no, ap : string80;
     si : boolean;
     g : integer;
  begin
     clrscr;
      writeln('   Resumen Nota Final ');
      writeln;
      write('  Entre Nombre   : ');
      readln(nom);
      write('  Entre Apellido : ');
      readln(ape);
      pasa_amayus(nom);
      pasa_amayus(ape);
      assign(f,alum);
  {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('   Error De Archivo O No Existe Pulse Una Tecla');
       readkey;
    end
  else
     begin
        si := false;
        for p := 0 to filesize(f) - 1 do
        begin
           seek(f,p);
           read(f,dato);
           no := dato.nombre;
           ap := dato.apellido;
           pasa_amayus(no);
           pasa_amayus(ap);
           if (no = nom) and (ap = ape) then
           begin
              h := p;
              si := true;
              break;
           end;
        end;
          if si = true then
          begin
             for g := 1 to dato.con - 1 do
             begin
               dato.notafinal := dato.notafinal + dato.notas[g]
             end;
             dato.notafinal := dato.notafinal / dato.con - 1;
             seek(f,h);
             write(f,dato);
             close(f);
          end
      else
         begin
            writeln('  Nombre Y Apellido No Encontrados Pulse Una Tecla');
            readkey;
            close(f);
         end;
       end;
    end;
 
  procedure menu;
  var
    sal : boolean;
    tecla : char;
    begin
        sal := false;
        fillchar(dato,sizeof(dato),0);
     repeat
         clrscr;
         writeln('   ****** Menu Jeneral ******');
         writeln;
         writeln('    1 = Entrada De Datos');
         writeln('    2 - Presenta Datos');
         writeln('    3 = Entrada Mas Notas');
         writeln('    4 = Nota Final');
         writeln('    5 = Salir');
         writeln;
         writeln('   \\\\ Elija Opcion ////');
       repeat
           tecla := readkey;
       until tecla in['1','2','3','4','5'];
       clrscr;
    case tecla of
 '1' : entrada_datos(dato);
 '2' : presenta_alumnos;
 '3' : nuevasnotas;
 '4' : notafinal;
 '5' : sal := true;
    end;
     until sal = true;
   end;
 
  begin
     menu;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil

Ayuda Ejercicio en Pascal

Publicado por Andrea (3 intervenciones) el 05/05/2016 05:03:10
Hola Muchas Gracias Ramón me ayudaste mucho!!
solo falto agregarle el seudocodigo para ordenar alfabéticamente por apellido en forma ascendente
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar