Return to Snippet

Revision: 60638
at November 12, 2012 04:15 by tdoric


Initial Code
#include <iostream>
#include <cstring>
using namespace std;
 
struct ljubimac
{
  int kod;
  char vrsta[50];
  char naziv[50];
  int cijena;
  int d;
  int m;
  int g;
};
struct lis
{
  ljubimac 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 je nedefinirana!" << 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(ljubimac x, lis *p, lis *list)
{
  lis *novi = new lis;
  p = PreviousL(p, list);
  novi->values = x;
  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;
}
ljubimac 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
ovo je lista pomocu pokazivaca potrebna za izvrsavanje koda u glavnom programu

Initial Title
lista_pokazivac.h

Initial Tags

                                

Initial Language
C++