Return to Snippet

Revision: 35811
at November 14, 2010 01:22 by mivukovi


Initial Code
#include <cstdlib>				
#include <iostream>					
#include <string.h>					

#include "stog_pokazivac.h"				
//#include "stog_polje.h"				
							
using namespace std;					

stogstog stog;													
void ukrcaj()						
{   
	automobil b;					
    cout << endl << "Marka: ";	
    cin >> b.marka;
	cout << "Model: ";
	cin >> b.model;
	cout << "Serijski broj: ";
	cin >> b.serijskibroj;
	do { cout << "Godina proizvodnje: ";
	     cin >> b.godina;
        }while(b.godina<1995 || b.godina>2010);
	PushS(b, stog);
	cout << endl;					
}

void autokuca1(char iskljuci[], int god)			
{
	stogstog pomocni_stog;												
	pomocni_stog = (stogstog)malloc(sizeof(struct tstog));		
	InitS(pomocni_stog);						
	automobil b;																
							
		while (!IsEmptyS(stog))					 
		{
			b = TopS(stog);					
			PopS(stog);					

			if ((strcmp(b.marka, iskljuci) != 0) && (b.godina > god)) 		 
			{								
			  cout << b.serijskibroj<< "\t\t\t"  << b.marka << "\t\t"<<  b.model<< "\t\t"<< b.godina << endl;									
				
			}
			else									
			{
				PushS(b, pomocni_stog);						
			}

		while (!IsEmptyS(pomocni_stog))				
		{
			b = TopS(pomocni_stog);				
			PushS(b, stog);					
			PopS(pomocni_stog);			
		}																	
	}
}

void autokuca2(char marka[])	
					
{
	if (!IsEmptyS(stog))						
	{
		automobil b = TopS(stog);				
		PopS(stog);															
		int usporedba = strcmp(b.marka, marka);			
		if (usporedba == 0)					
		{           
           cout << b.serijskibroj<< "\t\t\t"  << b.marka << "\t\t"<<  b.model<< "\t\t"<< b.godina << endl;		
		}
		autokuca2(marka);
		if (usporedba != 0) PushS(b, stog);		
		}							
	}

void pomocni()						
{										
	stogstog pomocni_stog;														
	pomocni_stog = (stogstog)malloc(sizeof(struct tstog));		
	InitS(pomocni_stog);					
	automobil b;														
		while (!IsEmptyS(stog))													
		{
			b = TopS(stog);					
			PushS(b, pomocni_stog);				
			PopS(stog);					
		}
		while (!IsEmptyS(pomocni_stog))				
		{
			b = TopS(pomocni_stog);				
			cout << b.serijskibroj<< "\t\t\t"  << b.marka << "\t\t"<<  b.model<< "\t\t"<< b.godina << endl;
			PushS(b, stog);					
			PopS(pomocni_stog);				
		}	
}

int main(int argc, char *argv[])				
{
	int izbor = 9;						
    int br;							
    
	stog = (stogstog)malloc(sizeof(struct tstog));			
	InitS(stog);							
    
	do 
	{	system("cls");
        cout << endl;
        cout << "------ I Z B O R N I K----------"<< endl;						
		cout << "1. Upis    automobila" << endl;
		cout << "2. Iskrcaj automobila" << endl;
		cout << "9. Izlaz" << endl ;
        cout<<"________________________________"<<endl << endl;	
		cout << "Vas izbor je: ";
		cin >> izbor;
	
		switch (izbor)						
        	{
		  case 1:
			ukrcaj();					
            break;
		        
		  case 2:
		 do { 
              system("cls");
              int izbor;
             cout << endl;
             cout << " ----ISKRCAJ AUTOMOBILA----- " << endl;
             cout << " 1. Automobili proizvedeni nakon 2006.godine i nisu marke Audi " << endl;
             cout << " 2. Automobili koji su marke Audi " << endl;
             cout <<"_________________________________________"<<endl;
             cout << "Vas izbor: " ;
             cin >>izbor;
             switch (izbor) {
                    case 1:
                         cout<<endl;
                         cout <<"Serijski broj"<< "\t\t" <<"Marka" << "\t\t"<< " Model " << "\t\t" << "Godina" << endl;
                         cout <<"----------------------------------------------------------------"<<endl;
                         autokuca1((char *)"audi", 2006);
                         cout<<endl;
                         cout << "Stanje u pomocnom stogu:" << endl;
                         cout <<"Serijski broj"<< "\t\t" <<"Marka" << "\t\t"<< " Model " << "\t\t" << "Godina" << endl;
                         cout <<"----------------------------------------------------------------"<<endl;
                         
                         pomocni();	
                         system("pause");
                          break;
                    case 2: 
                         cout<<endl;
                          cout <<"Serijski broj"<< "\t\t" <<"Marka" << "\t\t"<< " Model " << "\t\t" << "Godina" << endl;
                          cout <<"----------------------------------------------------------------";
                          cout << endl;	
                          cout << "Stanje u pomocnom stogu:" << endl;
                         cout <<"Serijski broj"<< "\t\t" <<"Marka" << "\t\t"<< " Model " << "\t\t" << "Godina" << endl;
                         cout <<"----------------------------------------------------------------"<<endl;
		               	autokuca2((char *)"audi");				
                        system("pause");
                        break;
                   
                    }//switch
                    }while (izbor != 3); 		
		  		        		
        	}
	} while (izbor != 9);						
    
    						
}

Initial URL

                                

Initial Description

                                

Initial Title
osnovni program

Initial Tags

                                

Initial Language
C++