/ Published in: C++
Lista implementirana pomoću polja.
Expand |
Embed | Plain Text
#include <string> using namespace std; struct zivotinje{ int sifra; char vrsta[30]; char naziv[30]; int cijena; string datum; }; struct tlista{ zivotinje sve [1000]; int cursor; }l; typedef int tip; int FirstL(tlista l){ return 0; } int EndL(tlista l){ return l.cursor; } int NextL( int p, tlista l){ return p+1; } int PreviousL(int p, tlista l){ return p-1; } int LocateL(zivotinje x, tlista l){ for(int i=0; i<l.cursor;i++) if(x.sifra==l.sve[i].sifra) return i; } int InsertL(zivotinje x, int p, tlista &l){ l.cursor++; for(int i=l.cursor-1;i>p;i--) l.sve[i]=l.sve[i-1]; l.sve[p]=x; return 1; } void DeleteL(int p, tlista &l){ for(int i=p;i<l.cursor;i++) l.sve[i]=l.sve[i+1]; l.cursor--; } zivotinje RetrieveL(int p, tlista l){ return l.sve[p]; } void DeleteAllL(tlista & l){ l.cursor=0; } void InitL(tlista l){ l.cursor=0; }
You need to login to post a comment.
