Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // datoteka zaglavlja za implementaciju liste pomocu polja
- #include<iostream>
- using namespace std;
- struct tpacijent {
- int JMBG;
- char ime[50];
- int starost;
- };
- struct lista {
- tpacijent values[1000];
- int cursor;
- };
- lista pacijenti;
- int EndL(lista L) {
- return L.cursor;
- }
- int FirstL(lista L) {
- if(L.cursor != 0) return 0;
- else return EndL(L);
- }
- int NextL(int p, lista L) {
- if(p == (EndL(L) - 1)) return EndL(L);
- else return p+1;
- }
- int PreviousL(int p, lista L) {
- if(p == FirstL(L)) return EndL(L);
- else return p-1;
- }
- int LocateL(int p, lista L) {
- int a = 0;
- while(a != EndL(L)) {
- if(L.values[a].JMBG == p) return a;
- a++;
- }
- return EndL(L);
- }
- void InsertL(tpacijent pacijent, int p, lista &L) {
- int a = EndL(L);
- L.cursor++;
- while(1) {
- L.values[a] = L.values[a-1];
- if(a == p) {
- L.values[p] = pacijent;
- return;
- }
- a--;
- }
- }
- void DeleteL(int p, lista &L) {
- while(p < (EndL(L) - 1)) {
- L.values[p] = L.values[p+1];
- p++;
- }
- L.cursor--;
- }
- tpacijent RetrieveL(int p, lista L) {
- return L.values[p];
- }
- void DeleteAll(lista &L) {
- L.cursor = 0;
- }
- void InitL(lista &L) {
- L.cursor = 0;
- }
Add Comment
Please, Sign In to add comment