Pascal/Turbo Pascal - Ejercicio Pascal

 
Vista:

Ejercicio Pascal

Publicado por dario (42 intervenciones) el 27/07/2015 10:45:02
Tengo este ejercicio y tiene que hacerse en pascal. Mi duda es: se puede hacer con arrays multidimensionales o con registros multidimensionales.

Una universidad x que posee 3 facultades y cada facultad posee 3 carreras, donde cada carrera tiene asignadas al menos 4 asignaturas. Requiere un programa que muestre cual es el mejor alumno por asignatura, por facultad, y el mejor estudiante de la universidad. Este debe registrar el nombre y nota por estudiante, además demostrar, el estudiante con más bajo promedio.
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

Ejercicio Pascal

Publicado por ramon (2158 intervenciones) el 01/08/2015 23:11:58
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
{A ver si esto ayuda a seguir }
 
 program universidad;
  uses
     crt;
  const
     univfacul : array[1..3] of string[20] =
     ('San Paulo','La Anunciata','Andresianos');
     carre : array[1..3] of string[12] =  (
     'Ciencias','Quimica','Letras');
     asign : array[1..3,1..4] of string[12] = (
     ('Matematicas','Fisica','Quimica','Dibujo'),
     ('Quimica','Fisica','Biologia','Matematicas'),
     ('','','',''));
 
  type
  estudiante = record
            facul : char;
          carrera : char;
          asignat : char;
           nombre : string;
           puntos : real;
          end;
 
  var
    datos : estudiante;
    f : file of estudiante;
    cont : integer;
 
 
   procedure iniciaestado;
   begin
      fillchar(datos,sizeof(datos),0);
   end;
 
   procedure guardadatos(d : estudiante);
   begin
      assign(f,'univesid.dat');
  {$I-} reset(f); {$I+}
     if ioresult <> 0 then
     begin
       rewrite(f);
       seek(f,0);
       write(f,d);
       close(f);
     end
  else
     begin
       seek(f,filesize(f));
       write(f,d);
       close(f);
     end;
   end;
 
 
   procedure entrada_datos;
   var
    x, a : integer;
    tec : char;
   begin
      gotoxy(10,3);write('Facultad N. [1,2,3] : ');
      gotoxy(32,3);
      repeat
         tec := readkey;
      until tec in['1','2','3'];
      datos.facul := tec;
      gotoxy(31,3);write(univfacul[ord(tec) - 48]);
      gotoxy(10,4);write('Carrera N. [1,2,3] : ');
      gotoxy(31,4);
      repeat
         tec := readkey;
      until tec in['1','2','3'];
      datos.carrera := tec;
      gotoxy(31,4);write( carre[ord(tec) - 48]);
      a := ord(tec) - 48;
      gotoxy(10,5);write('Asignatura N. [1,2,3,4] : ');
      gotoxy(36,5);
      repeat
         tec := readkey;
      until tec in['1','2','3','4'];
      datos.asignat := tec;
      gotoxy(36,5);write(asign[a,ord(tec) - 48]);
      gotoxy(10,6);write('Entre Nombre  : ');
      gotoxy(26,6);readln(datos.nombre);
      gotoxy(10,7);write('Entre Puntuacion  : ');
      gotoxy(30,7);readln(datos.puntos);
      guardadatos(datos);
   end;
 
   procedure muestra_estudiantes;
   var
      t : longint;
      temp : estudiante;
   begin
    assign(f,'univesid.dat');
  {$I-} reset(f); {$I+}
     if ioresult <> 0 then
     begin
        writeln('   Error De Archivo O Falta Pulse Una Tecla');
        readkey;
     end
  else
     begin
        writeln;
        writeln('    ****  Lista De Estudiantes ***');
        writeln;
        for t := 0 to filesize(f) - 1 do
        begin
           seek(f,t);
           read(f,temp);
           writeln('    ',univfacul[ord(temp.facul) - 48],'    ',
           carre[ord(temp.carrera) - 48],'    ',
           asign[ord(temp.carrera) - 48,ord(temp.asignat) - 48],
           '    ',temp.nombre,'    ',temp.puntos:0:2);
        end;
           writeln;
           writeln('    Pulse Una Tecla');
           readkey;
       end;
   end;
 
   procedure mejor_por_asignatura;
   var
     asig : array[1..4] of estudiante ;
     g : longint;
     dd : estudiante;
     tt : file of estudiante;
     z : integer;
    begin
        assign(tt,'univesid.dat');
  {$I-} reset(tt); {$I+}
     if ioresult <> 0 then
     begin
        writeln('   Error De Archivo O Falta Pulse Una Tecla');
        readkey;
     end
  else
     begin
        for z := 1 to 4 do
        fillchar(asig[z],sizeof(asig[z]),0);
        for g := 0 to filesize(tt) - 1 do
        begin
           seek(tt,g);
           read(tt,dd);
           if dd.puntos > asig[ord(dd.carrera) - 48].puntos then
           begin
           fillchar(asig[ord(dd.carrera) - 48],sizeof(asig[ord(dd.carrera) - 48]),0);
           asig[ord(dd.carrera) - 48] := dd;
           end;
        end;
          close(tt);
          clrscr;
          writeln;
          writeln('      ****** Mejores Por Asignatura Es ******');
          writeln;
          for z := 1 to 4 do
          if asig[z].puntos <> 0 then
          writeln('    ',univfacul[ord(asig[z].facul) - 48],'    ',
                  carre[ord(asig[z].carrera) - 48],'    ',
                  asign[ord(asig[z].carrera) - 48,ord(asig[z].asignat) - 48],'    ',
                  asig[z].nombre,'    ',asig[z].puntos:0:2);
         writeln;
         writeln('    Pulse Una Tecla');
         readkey;
     end;
    end;
 
 
    procedure mejor_por_facultad;
   var
     asig : array[1..3] of estudiante ;
     g : longint;
     mejor, dd : estudiante;
     tt : file of estudiante;
     z : integer;
    begin
        assign(tt,'univesid.dat');
  {$I-} reset(tt); {$I+}
     if ioresult <> 0 then
     begin
        writeln('   Error De Archivo O Falta Pulse Una Tecla');
        readkey;
     end
  else
     begin
        for z := 1 to 3 do
        fillchar(asig[z],sizeof(asig[z]),0);
        for g := 0 to filesize(tt) - 1 do
        begin
           seek(tt,g);
           read(tt,dd);
           if dd.puntos > mejor.puntos then
           begin
           asig[ord(dd.facul) - 48] := dd;
           fillchar(mejor,sizeof(mejor),0);
           mejor := dd;
           end;
        end;
        close(tt);
        clrscr;
        writeln;
        writeln('      ***** Mejor Por Facultad *****');
        writeln;
        writeln('    ',univfacul[ord(mejor.facul) - 48],'    ',
                       carre[ord(mejor.carrera) - 48],'    ',
                   asign[ord(mejor.carrera) - 48,ord(mejor.asignat) - 48],
                   '    ',mejor.nombre,'    ',mejor.puntos:0:2);
        writeln;
        writeln('    Pulse Una Tecla');
        readkey;
      end;
   end;
 
 
 
   procedure menu;
   var
     te : char;
     sal : boolean;
   begin
      sal := false;
   repeat
       clrscr;
       writeln('  ***** Menu *****');
       writeln;
       writeln('   1 = Entrada Estudiante');
       writeln('   2 = Lista Estudiantes');
       writeln('   3 = Mejor Asignatura');
       writeln('   4 = Mejor Por Falcultad');
       writeln('   5 = Salir');
       writeln;
       writeln('   Elija Opcion ');
     repeat
          te := readkey;
     until te in['1','2','3','4','5'];
     clrscr;
    case te of
 '1' : entrada_datos;
 '2' : muestra_estudiantes;
 '3' : mejor_por_asignatura;
 '4' : mejor_por_facultad;
 '5' : sal := true;
   end;
  until sal = true;
  end;
 
 
 
   begin
      clrscr;
      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
0
Comentar