Return to Snippet

Revision: 35850
at November 14, 2010 23:30 by SPcakaSP


Initial Code
#include <iostream>
using namespace std;

struct tautomobil {
   int sb;
   char proizvodac[25];
   char model[20];
   int godina;
} automobil;
       
struct stog {
   int sb[40];
   char proizvodac[40][25];
   char model[40][20];
   int godina[40];
   int kursor;
};

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

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

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

stog* InitS (stog* S) {
   S = new stog;
   S -> kursor = 20;
   return S;
} 

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

Initial URL

                                

Initial Description

                                

Initial Title
Header stog_polje.h

Initial Tags
podataka

Initial Language
C++