Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. program Project1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. type lista=^tlista;
  9. tlista=record
  10. imie:string;
  11. nazwisko:string;
  12. data:integer;
  13. wsk:^tlista;
  14.  
  15. end;
  16.  
  17. procedure dodaj (var pocz:lista);
  18. var
  19. nowy:lista;
  20. begin
  21. new (nowy);
  22. writeln ('Podaj imie');
  23. readln (nowy^.imie);
  24. writeln ('Podaj nazwisko');
  25. readln (nowy^.nazwisko);
  26. writeln ('Podaj rok urodzenia');
  27. readln (nowy^.data);
  28. if pocz=nil then nowy^.wsk:=nil else nowy^.wsk:=pocz;
  29. pocz:=nowy;
  30. end;
  31.  
  32. procedure wyswietl (pocz:lista);
  33. begin
  34. if pocz=nil then
  35. begin
  36. writeln ('Stos jest pusty');
  37. exit;
  38. end
  39. else
  40. begin
  41. while pocz<>nil do
  42. writeln(pocz^.imie);
  43. writeln(pocz^.nazwisko);
  44. writeln(pocz^.data);
  45. pocz:=pocz^.wsk
  46. end;
  47. end;
  48.  
  49. procedure usun (var pocz:lista);
  50. var
  51. del:lista;
  52. begin
  53. if pocz=nil then
  54. begin
  55. writeln ('Stos jest pusty');
  56. exit;
  57. end
  58. else
  59. begin
  60. del:=pocz;
  61. pocz:=pocz^.wsk;
  62. dispose(del);
  63. end;
  64. end;
  65.  
  66. var
  67. dana:lista;
  68. n:integer;
  69. begin
  70. dana:=nil;
  71. repeat
  72. writeln('**********************************************************');
  73. writeln('1. Wyswietl stos');
  74. writeln('2. Dodaj do stosu');
  75. writeln('3. Usun ze stosu');
  76. writeln('4. Zamknij program');
  77. writeln('**********************************************************');
  78. writeln('Co wybierasz');
  79. readln(n);
  80. until n=4;
  81. case n of
  82. 1:wyswietl(dana);
  83. 2:dodaj(dana);
  84. 3:usun(dana);
  85. end;
  86. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement