Guest User

Untitled

a guest
Jun 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. struct tpac {
  5. int mb;
  6. char ime[20];
  7. int godine;
  8. } pacijent;
  9.  
  10. struct list {
  11. int mb[100];
  12. char ime[100][20];
  13. int godine[100];
  14. int pozicija;
  15. };
  16.  
  17. typedef int elem;
  18.  
  19. list* Init(list* L) {
  20. L = new list;
  21. L->pozicija = 0;
  22. return L;
  23. }
  24. elem End(list* L) {
  25. return L->pozicija;
  26. }
  27. elem First(list* L) {
  28. if(L->pozicija==0)
  29. return End(L);
  30. else
  31. return 0;
  32. }
  33. elem Next(elem p, list* L) {
  34. if (p==End(L))
  35. return 0;
  36. else
  37. return p=p+1;
  38. }
  39. elem Previous(elem p, list* L) {
  40. if (p==First(L))
  41. return 0;
  42. else
  43. return p=p-1;
  44. }
  45. int Insert(tpac neki, int p, list* L) {
  46. if (p>L->pozicija)
  47. return 0;
  48. else {
  49. L->pozicija++;
  50. for (int i=L->pozicija-1; i>=p; i--) {
  51. L->mb[i+1] = L->mb[i];
  52. strcpy(L->ime[i+1], L->ime[i]);
  53. L->godine[i+1] = L->godine[i];
  54. }
  55. L->mb[p] = neki.mb;
  56. strcpy(L->ime[p],neki.ime);
  57. L->godine[p] = neki.godine;
  58. return 1;
  59. }
  60. }
  61. elem Locate(tpac neki, list* L){
  62. for (int i=0;i < L->pozicija;i++) {
  63. if (L->mb[i] == neki.mb)
  64. return i;
  65. }
  66. return End(L);
  67. }
  68. tpac Retreive(elem p, list* L){
  69. pacijent.mb = L->mb[p];
  70. strcpy(pacijent.ime,L->ime[p]);
  71. pacijent.godine = L->godine[p];
  72. return pacijent;
  73. }
  74. int Delete(elem p, list* L) {
  75. for (int i=p; i< L->pozicija-1;i++) {
  76. L->mb[i] = L->mb[i+1];
  77. strcpy(L->ime[i], L->ime[i+1]);
  78. L->godine[i] = L->godine[i+1];
  79. }
  80. L->pozicija--;
  81. return 1;
  82. }
  83. void DeleteAll(list* L) {
  84. L->pozicija = 0;
  85. }
Add Comment
Please, Sign In to add comment