stog_polje.h





0
Date Submitted Sun. Nov. 14th, 2010 3:43 PM
Revision 1 of 1
Beginner bart-man
Tags stog_polje.h
Comments 0 comments
stog preko polja


struct tautomobil {
   int sb;
   char proizvodac[30];
   char model[30];
   int godina;
} automobil;
       
struct stack {
   int sb[21];
   char proizvodac[21][30];
   char model[21][30];
   int godina[21];
   int cursor;
};

tautomobil TopS (stack* S){
   if(S->cursor != 20) {
     automobil.sb = S->sb[S->cursor+1];
     strcpy(automobil.proizvodac, S->proizvodac[S->cursor+1]);
     strcpy(automobil.model, S->model[S->cursor+1]);
     automobil.godina = S->godina[S->cursor+1];
     return automobil;
   }
}

void PushS (tautomobil x, stack* S){
  if(S->cursor>=0) {
   S->sb[S->cursor] = x.sb;
   strcpy(S->proizvodac[S->cursor], x.proizvodac);
   strcpy(S->model[S->cursor], x.model);
   S->godina[S->cursor] = x.godina;
   S->cursor--;
  }
}

void PopS (stack* S) {
   if (S->cursor <= 20)
     S->cursor++;
}

stack* InitS (stack* S) {
   S = new stack;
   S -> cursor = 20;
   return S;
}

bool IsEmptyS (stack* S) {
   if (S->cursor == 20) return 1;
   else return 0;     
}   


 

andrija bartolic

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Votes Down