-
April 30th, 2009, 11:37 AM
#1
help on converting pascal to C++
I need to do a Homework and its been buzzing my skull cracked open.
I have to write a program on c++ or modify this pascal code.
to write,erase or find a record in a archive.
the record has to have the camp:
empid (negative if the record is erased)
apellido
nombre
edad
salario
Pascal code
program empleados;
type persona=record
nombre,apellido:string;
edad,empid,instruccion:integer;
salario:real;
end;
var
empleado: ^persona;
plantilla: file of persona;
estapersona:integer;
siono:string;
begin
new(empleado);
estapersona:=0;
assign(plantilla,'empleados.dat');
{Anadir record}
reset(plantilla);
while not eof(plantilla) do
begin
read(plantilla,empleado^);
if abs( empleado^.empid) >estapersona then estapersona:=abs(empleado^.empid);
end;
{repeat}
repeat
write('Nombre del empleado: ');
readln(empleado^.nombre);
write('Apellido: ');
readln(empleado^.apellido);
write('Edad: ');
readln(empleado^.edad);
write('Salario: ');
readln(empleado^.salario);
writeln('Verifique:');
writeln('Nombre:', empleado^.nombre);
writeln('Apellido:', empleado^.apellido);
writeln('Edad:', empleado^.edad);
writeln('Salario:', empleado^.salario);
write('Correcto Si/No:');
readln(siono);
until siono='Si';
inc(estapersona);
empleado^.empid:=estapersona;
write(plantilla,empleado^);
{write('Otro? Si/No');
readln(siono);
until siono='No';}
close(plantilla);
{/Anadir record}
reset(plantilla);
while not eof(plantilla) do
begin
read(plantilla,empleado^);
writeln(empleado^.nombre,' ',empleado^.apellido);
end;
close(plantilla);
end.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|