Código de Pascal/Turbo Pascal - Practica

<<>>
sin imagen de perfil

Practicagráfica de visualizaciones


Pascal/Turbo Pascal

Publicado el 1 de Agosto del 2021 por Jose Miguel (9 códigos)
619 visualizaciones desde el 1 de Agosto del 2021
program practica(input, output,f1,fmovi,f2);
type
cadena30 = packed array[1..30] of char;
opcion=(a,m);
tfalant = record
an_nma:1..999;
an_nom:cadena30;
an_dir:cadena30;
an_rva:boolean;
an_nfal:0..365;
an_nsus:0..25;
end;

tmovi = record
mv_nma:1..999;
mv_nom:cadena30;
mv_dir:cadena30;
mv_tip:opcion;
end;

tfalum = record
al_nma:1..999;
al_nom:cadena30;
al_dir:cadena30;
end;

ffalant = file of tfalant;
fmove = file of tmovi;
ffalum = file of tfalum;

var
i:integer;
c:char;
f1:ffalant;
f2:ffalum;
fmovi:fmove;
rfalant:tfalant;
rmovi:tmovi;
rfalum:tfalum;
seguir:boolean;

function continuar(raux:tfalant):boolean;
begin
continuar:= true;
if raux.an_rva=false then
begin
writeln('El alumno,',raux.an_nom,'no tiene reserva.');
continuar:= false;
end;
if raux.an_nfal>50 then
begin
writeln('El alumno, ',raux.an_nom,' tiene mas de 50 faltas.');
continuar:=false;
end;
if raux.an_nsus>3 then
begin
writeln('El alumno, ',raux.an_nom,' tiene mas de 3 asignaturas suspensas');
continuar:= false;
end;
end;

procedure copy_falum(raux:tfalant;var rfalum:tfalum);
begin
rfalum.al_nma:=raux.an_nma;
rfalum.al_nom:=raux.an_nom;
rfalum.al_dir:=raux.an_dir;
end;

procedure copy_falum2(raux2:tfalant;raux:tmovi;var rfalum:tfalum);
begin
rfalum.al_nma:=raux.mv_nma;
if raux.mv_tip=m then
rfalum.al_nom:=raux2.an_nom
else
rfalum.al_nom:=raux.mv_nom;
rfalum.al_dir:=raux.mv_dir;
end;

procedure busqueda(raux:tmovi; var raux2:tfalant;var encontrado:boolean);
var
f1:ffalant;
begin
encontrado:=false;
assign(f1,'falant.dat');
reset(f1);
while (not eof(f1)) and (encontrado=false) do
begin
read(f1,raux2);
if raux2.an_nma=raux.mv_nma then
encontrado:= true;
end;
end;

begin
assign(fmovi,'movi.dat');
rewrite(fmovi);
while not eof do
begin
for i:=1 to 24 do writeln;
write('Escriba el n£mero de matr¡cula del alumno: ');
readln(rmovi.mv_nma);
write('Escriba el nombre y los apellidos del alumno: ');
i:=1;
while not eoln do
begin
read(rmovi.mv_nom[i]);
i:=i+1;
end;
for i:=1 to 30 do rmovi.mv_nom[i]:=' ';
write('Escriba la direcci¢n del alumno: ');
readln;
i:=1;
while not eoln do
begin
read(rmovi.mv_dir[i]);
i:=i+1;
end;
for i:=i to 30 do rmovi.mv_dir[i]:=' ';
write('Tipo de operacion que desea realizar (a/m) :');
c:='w';
while (c<>'a') and (c<>'m') do
read(c);
case c of
'a': rmovi.mv_tip:=a;
'm': rmovi.mv_tip:=m;
end;
write('N£mero de faltas en el curso anterior: ');
readln(rfalant.an_nfal);
write('N£mero de asignaturas suspensas: ');
readln(rfalant.an_nsus);
write('Si no desea introducir otro registro pulse CTRL-Z ');
write(fmovi,rmovi);
readln;

end;
assign(f1,'falant.dat');
reset(f1);
assign(f2,'falum.dat');
rewrite(f2);
reset(fmovi);
read(f1,rfalant);
read(fmovi,rmovi);
writeln;


for i:=1 to 24 do writeln;
while (not eof(fmovi)) and (not eof(f1)) do
begin
if rfalant.an_nma<rmovi.mv_nma then
begin
seguir:=continuar(rfalant);
if seguir=true then
begin
copy_falum(rfalant,rfalum);
write(f2,rfalum);
end;
read(f1,rfalant)
end
else
begin
if rmovi.mv_nma=rfalant.an_nma then
begin
if rmovi.mv_tip=a then
begin
writeln('Error, no se puede dar de alta a',rmovi.mv_nma);
end
else
begin
seguir:=continuar(rfalant);

if seguir=true then
begin
copy_falum2(rfalant,rmovi,rfalum);
write(f2,rfalum);
end;
read(f1,rfalant);
read(fmovi,rmovi);
end;
end
else
begin
if rmovi.mv_tip=a then
begin
copy_falum2(rfalant,rmovi,rfalum);
write(f2,rfalum);
end
else
writeln('Error, no se puede modificar al alumno ',rmovi.mv_nma,'anulado.');
read(fmovi,rmovi);
end;
end;
end;
while not eof(f1) do
begin
seguir:=continuar(rfalant);
if seguir=true then
begin
copy_falum(rfalant,rfalum);
write(f2,rfalum);
end;
read(f1,rfalant);
end;
seguir:=continuar(rfalant);
if seguir=true then
begin
copy_falum(rfalant,rfalum);
write(f2,rfalum);
end;
while not eof(fmovi) do
begin
if rmovi.mv_tip=m then
begin
busqueda(rmovi,rfalant,seguir);
if seguir=false then
writeln('Error, no puede modificarse al alumno ',rmovi.mv_nom, 'ya que no est  matriculado.')
else
end
else
begin
copy_falum2(rfalant,rmovi,rfalum);
write(f2,rfalum);
end;
read(fmovi,rmovi);
end;
if rmovi.mv_tip= m then
begin
busqueda(rmovi,rfalant,seguir);
if seguir=false then
begin
writeln('Error, no puede modificarse al alumno',rmovi.mv_nom);
end
else
begin
copy_falum2(rfalant,rmovi,rfalum);
write(f2,rfalum);
end;
end
else
begin
copy_falum2(rfalant,rmovi,rfalum);
write(f2,rfalum);
end;
close(f1);
close(f2);
close(fmovi);
readln;
end.

Requerimientos

Sistema Operativo Windows 10
Paquete TPWDB
Paquete DosBox 0.74-3

Versión 1.0

Publicado el 1 de Agosto del 2021gráfica de visualizaciones de la versión: Versión 1.0
620 visualizaciones desde el 1 de Agosto del 2021
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

Práctica en TurboPascal utilizando DosBox 0.74-3 en la que debes introducir el número de matricula del alumno, nombre, dirección, reserva (a ó m) , número de faltas en clase y número de asignaturas suspensas. Así realizando un bucle para un número infinito de alumnos.
Indicar que faltaría mostrar por pantalla el fichero ffalant de todos los alumnos introducidos.
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
program practica(input, output,f1,fmovi,f2);
type
  cadena30 = packed array[1..30] of char;
  opcion=(a,m);
  tfalant = record
             an_nma:1..999;
             an_nom:cadena30;
             an_dir:cadena30;
             an_rva:boolean;
             an_nfal:0..365;
             an_nsus:0..25;
            end;
 
  tmovi = record
            mv_nma:1..999;
            mv_nom:cadena30;
            mv_dir:cadena30;
            mv_tip:opcion;
          end;
 
  tfalum = record
             al_nma:1..999;
             al_nom:cadena30;
             al_dir:cadena30;
           end;
 
  ffalant = file of tfalant;
  fmove = file of tmovi;
  ffalum = file of tfalum;
 
var
  i:integer;
  c:char;
  f1:ffalant;
  f2:ffalum;
  fmovi:fmove;
  rfalant:tfalant;
  rmovi:tmovi;
  rfalum:tfalum;
  seguir:boolean;
 
function continuar(raux:tfalant):boolean;
begin
  continuar:= true;
  if raux.an_rva=false then
  begin
    writeln('El alumno,',raux.an_nom,'no tiene reserva.');
    continuar:= false;
  end;
  if raux.an_nfal>50 then
  begin
    writeln('El alumno, ',raux.an_nom,' tiene mas de 50 faltas.');
    continuar:=false;
  end;
  if raux.an_nsus>3 then
  begin
    writeln('El alumno, ',raux.an_nom,' tiene mas de 3 asignaturas suspensas');
    continuar:= false;
  end;
end;
 
procedure copy_falum(raux:tfalant;var rfalum:tfalum);
begin
  rfalum.al_nma:=raux.an_nma;
  rfalum.al_nom:=raux.an_nom;
  rfalum.al_dir:=raux.an_dir;
end;
 
procedure copy_falum2(raux2:tfalant;raux:tmovi;var rfalum:tfalum);
begin
   rfalum.al_nma:=raux.mv_nma;
   if raux.mv_tip=m then
     rfalum.al_nom:=raux2.an_nom
   else
     rfalum.al_nom:=raux.mv_nom;
   rfalum.al_dir:=raux.mv_dir;
end;
 
procedure busqueda(raux:tmovi; var raux2:tfalant;var encontrado:boolean);
var
  f1:ffalant;
begin
  encontrado:=false;
  assign(f1,'falant.dat');
  reset(f1);
  while (not eof(f1)) and (encontrado=false) do
  begin
     read(f1,raux2);
     if raux2.an_nma=raux.mv_nma then
       encontrado:= true;
  end;
end;
 
begin
  assign(fmovi,'movi.dat');
  rewrite(fmovi);
  while not eof do
  begin
        for i:=1 to 24 do writeln;
        write('Escriba el n£mero de matr¡cula del alumno: ');
        readln(rmovi.mv_nma);
        write('Escriba el nombre y los apellidos del alumno: ');
        i:=1;
        while not eoln do
        begin
          read(rmovi.mv_nom[i]);
          i:=i+1;
        end;
        for i:=1 to 30 do rmovi.mv_nom[i]:=' ';
        write('Escriba la direcci¢n del alumno: ');
        readln;
        i:=1;
        while not eoln do
        begin
          read(rmovi.mv_dir[i]);
          i:=i+1;
        end;
        for i:=i to 30 do rmovi.mv_dir[i]:=' ';
        write('Tipo de operacion que desea realizar (a/m) :');
        c:='w';
        while (c<>'a') and (c<>'m') do
            read(c);
        case c of
          'a': rmovi.mv_tip:=a;
          'm': rmovi.mv_tip:=m;
        end;
        write('N£mero de faltas en el curso anterior: ');
        readln(rfalant.an_nfal);
        write('N£mero de asignaturas suspensas: ');
        readln(rfalant.an_nsus);
        write('Si no desea introducir otro registro pulse CTRL-Z ');
        write(fmovi,rmovi);
        readln;
 
  end;
  assign(f1,'falant.dat');
  reset(f1);
  assign(f2,'falum.dat');
  rewrite(f2);
  reset(fmovi);
  read(f1,rfalant);
  read(fmovi,rmovi);
  writeln;
 
 
  for i:=1 to 24 do writeln;
  while (not eof(fmovi)) and (not eof(f1)) do
  begin
     if rfalant.an_nma<rmovi.mv_nma then
     begin
       seguir:=continuar(rfalant);
       if seguir=true then
       begin
         copy_falum(rfalant,rfalum);
         write(f2,rfalum);
       end;
       read(f1,rfalant)
     end
     else
     begin
        if rmovi.mv_nma=rfalant.an_nma then
        begin
              if rmovi.mv_tip=a then
              begin
                  writeln('Error, no se puede dar de alta a',rmovi.mv_nma);
              end
              else
              begin
                seguir:=continuar(rfalant);
 
                if seguir=true then
                begin
                  copy_falum2(rfalant,rmovi,rfalum);
                  write(f2,rfalum);
                end;
                read(f1,rfalant);
                read(fmovi,rmovi);
              end;
        end
        else
        begin
           if rmovi.mv_tip=a then
           begin
              copy_falum2(rfalant,rmovi,rfalum);
              write(f2,rfalum);
           end
           else
              writeln('Error, no se puede modificar al alumno ',rmovi.mv_nma,'anulado.');
           read(fmovi,rmovi);
        end;
     end;
  end;
  while not eof(f1) do
  begin
    seguir:=continuar(rfalant);
    if seguir=true then
    begin
      copy_falum(rfalant,rfalum);
      write(f2,rfalum);
    end;
    read(f1,rfalant);
  end;
  seguir:=continuar(rfalant);
  if seguir=true then
  begin
    copy_falum(rfalant,rfalum);
    write(f2,rfalum);
  end;
  while not eof(fmovi) do
  begin
    if rmovi.mv_tip=m then
    begin
      busqueda(rmovi,rfalant,seguir);
      if seguir=false then
         writeln('Error, no puede modificarse al alumno ',rmovi.mv_nom, 'ya que no est  matriculado.')
      else
    end
    else
      begin
         copy_falum2(rfalant,rmovi,rfalum);
         write(f2,rfalum);
      end;
      read(fmovi,rmovi);
  end;
  if rmovi.mv_tip= m then
  begin
    busqueda(rmovi,rfalant,seguir);
    if seguir=false then
    begin
       writeln('Error, no puede modificarse al alumno',rmovi.mv_nom);
    end
    else
    begin
      copy_falum2(rfalant,rmovi,rfalum);
      write(f2,rfalum);
    end;
  end
  else
  begin
   copy_falum2(rfalant,rmovi,rfalum);
   write(f2,rfalum);
  end;
  close(f1);
  close(f2);
  close(fmovi);
  readln;
end.



Comentarios sobre la versión: Versión 1.0 (0)


No hay comentarios
 

Comentar la versión: Versión 1.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s7125