Guest User

Untitled

a guest
Jun 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Program ej2;
  2. const
  3. valoralto = 999999;
  4. type
  5. vivienda = record
  6. codigo : integer;
  7. precio : real;
  8. habitaciones : integer;
  9. descripcion : string[20];
  10. end;
  11. maestro = file of vivienda;
  12.  
  13. procedure leer(var m : maestro; var v : vivienda);
  14. begin
  15. if not eof(m) then
  16. read(m, v)
  17. else
  18. v.codigo := valoralto;
  19. end;
  20.  
  21. procedure agregar(var m : maestro; v : vivienda);
  22. var
  23. tmp : vivienda;
  24. posA : integer;
  25. begin
  26. {Leer la cabecera de la pila}
  27. leer(m,tmp);
  28. if tmp.codigo = 0 then
  29. {agregamos al final}
  30. posA := filesize(m)
  31. else begin
  32. posA := tmp.codigo;
  33. {actualizamos la cabecera}
  34. seek(m, posA);
  35. read(m, tmp);
  36. seek(m, 0);
  37. write(m, tmp);
  38. end;
  39. seek(m, posA);
  40. write(m, v)
  41. end;
  42.  
  43. procedure eliminar(var m : maestro; v : vivienda);
  44. var
  45. c,tmp : vivienda;
  46. posA : integer;
  47. begin
  48. leer(m,c);
  49. repeat leer(m, tmp) until ((tmp.descripcion = v.descripcion) or (tmp.codigo = valoralto));
  50. if tmp.descripcion = v.descripcion then begin
  51. tmp.codigo := c.codigo;
  52. c.codigo := filepos(m) - 1;
  53. seek(m, 0);
  54. write(m, c);
  55. seek(m, c.codigo);
  56. write(m, tmp);
  57. end;
  58. end;
  59.  
  60. var
  61. m : maestro;
  62. begin
  63. assign(m, 'maetro');
  64. rewrite(m);
  65. close(m)
  66. end.
Add Comment
Please, Sign In to add comment