Revision: 60535
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 11, 2012 04:27 by marcelic
Initial Code
using namespace std;
struct Zivotinja {
int sifra;
char vrsta[30];
char naziv[30];
float cijena;
struct {
int dan, mjesec,godina;
}datum_dostave;
};
typedef int element;
struct List {
Zivotinja zivotinja[10000];
int cursor;
};
typedef struct List lista;
element FirstL(lista *L) {
return 0;
}
element EndL(lista *L) {
return L->cursor;
}
element NextL(element p, lista *L) {
if(p==EndL(L)) return -1;
return p+1;
}
element PreviousL(element p, lista *L) {
if(p==FirstL(L)) return -1;
return p-1;
}
element LocateL (Zivotinja x, lista * L){
if (x.naziv == 0) {
for (element i=0; i < L->cursor; i++){
if (L->zivotinja[i].sifra== x.sifra) return i;
}
return L->cursor;
} else {
for (element i=0; i < L->cursor; i++){
if (L->zivotinja[i].naziv== x.naziv) return i;
}
return L->cursor;
}
}
int InsertL(Zivotinja x, element p, lista *L) {
L->cursor++;
for(int i=L->cursor-2; i>=p; i--) {
L->zivotinja[i+1]=L->zivotinja[i];
}
L->zivotinja[p]=x;
if(L->zivotinja[p].sifra==x.sifra) return 1;
else return 0;
}
int DeleteL(element p, lista *L) {
for(int i=p; i<L->cursor-1; i++) {
L->zivotinja[i]=L->zivotinja[i+1];
}
if(p>=FirstL(L) && p<L->cursor) {
L->cursor--;
return 1;
}
else return 0;
}
Zivotinja RetreiveL(element p, lista *L) {
return L->zivotinja[p];
}
void DeleteAllL(lista *L) {
L->cursor=0;
}
lista *InitL(lista *L) {
L=new lista;
L->cursor=0;
return L;
}
Initial URL
Initial Description
Implementacija liste pomocu polja
Initial Title
Evidencija zivotinja - lista_polje.h
Initial Tags
c++
Initial Language
C++