Return to Snippet

Revision: 60668
at November 12, 2012 05:42 by MFilip


Initial Code
#include <iostream>
#include <cstring>
using namespace std;
     
struct zivotinje
    {
    int sifra;
    char vrsta[50];
    char naziv[50];
    int cijena;
    int d;
    int m;
    int g;
    };
struct lis
    {
    zivotinje values;
    lis *next;
    };
lis *list = new lis;
typedef lis *element;
lis *EndL(lis *list)
    {
    lis *zadnji = list;
    while(zadnji->next)
    zadnji = zadnji->next;
    return zadnji->next;
    }
lis *FirstL(lis *list)
    {
    if(list == NULL)
            return EndL(list);
    else
        return list->next;
         }
lis *NextL(lis *p, lis *list)
    {
    lis *zadnji = list;
    while(zadnji->next)
                       zadnji = zadnji->next;
    if(p == zadnji)
    return EndL(list);
    if(p == EndL(list))
         cout << "Funkcija nije definirana" << endl;
    else
        return p->next;
    }
lis *PreviousL(lis *p, lis *list)
    {
    lis *prethodni = list;
    while(prethodni->next != p)
                          prethodni = prethodni->next;
    return prethodni;
    }
lis *LocateL(char x[], lis *list)
    {
    lis *tekuci = list->next;
    while(tekuci)
    {
        if((strncmp(x,tekuci->values.naziv,sizeof(x))==0) || (strncmp(x,tekuci->values.vrsta,sizeof(x))==0))
        return tekuci;
        tekuci = tekuci->next;
    }
    return EndL(list);
    }
void InsertL(zivotinje a, lis *p, lis *list)
    {
    lis *novi = new lis;
    p = PreviousL(p, list);
    novi->values = a;
    novi->next = p->next;
    p->next = novi;
    }
void DeleteL(lis *p, lis *list)
    {
    p = PreviousL(p, list);
    lis *tekuci = p->next;
    p->next = tekuci->next;
    delete tekuci;
    }
zivotinje RetreiveL(lis *p, lis *list)
    {
    return p->values;
    }
void DeleteAllL(lis *list)
    {
    lis* brisi = list->next;
    while(brisi)
    {
    list->next = brisi->next;
    delete brisi;
    brisi = list->next;
    }
    }
void InitL(lis *list)
    {
    list->next= NULL;
    }

Initial URL

                                

Initial Description
lista pokazivaci

Initial Title
lista_pokazivaci.h

Initial Tags

                                

Initial Language
C++