Return to Snippet

Revision: 35893
at November 15, 2010 03:28 by makruljac


Initial Code
GLAVNI PROGRAM
--------------

#include<iostream>
#include<cstring>

#include "stog_polje.h"


using namespace std;

int upis=0;

void dodaj(auti *a){
     char jos;
     int sb,gd;
     char pr[20],md[20];
     do{
         upis++;
         cout << "Serijski broj automobila: ";
         cin >> sb;
         cout << "Proizvodac automobila: ";
         cin.ignore();
         cin.getline(pr,20);
         cout << "Model automobila: ";
         cin.getline(md,20);
         opet:cout << "Godiste automobila: ";
         cin >> gd;
         if(gd<1995 || gd>2010){
                    cout << "Godiste automobila nije u danom rasponu!" << endl;
                    goto opet;
                    }
         PushS(sb,pr,md,gd,upis);
         cout << "Zelite jos? ";
         cin >> jos;
         }while(jos=='d');
     }

void ispis_bez_audi(auti *a,int br_zap){
     cout << "Auti proizvedeni poslije 2006.g i nisu marke Audi" << endl;
     cout << "-------------------------------------------------" << endl;
     for(int i=99-br_zap;i<=99;i++){
             TopS_bez(br_zap);
             br_zap++;}
     
     cout << "Stanje na stogu: " << endl;
     cout << "---------------" << endl;
     TopS(br_zap-1);
     }

int audi(int broj,int br_zap){
    if(broj==100){
                  cout << "Stanje na stogu: " << endl;
                  cout << "----------------" << endl;
                  TopS(br_zap);
                  return 1;}
    else{
        TopS_audi(br_zap); 
        return audi(broj+1,br_zap+1);}
     }

int main(){
    int izbor;
    auti *a=new auti; 
    int br_zap=0;   
    do{
        cout << endl;
        cout << "1.Unos novog automobila" << endl;
        cout << "2.Ispis automobila godista veceg od 2006 i bez marke Audi" << endl;
        cout << "3.Ispis svih automobila marke Audi" << endl;
        cout << "4.Izlaz iz programa" << endl;
        cout << "-----------------" << endl;
        cout << "Vas izbor? ";
        cin >> izbor;
        if(izbor==1)br_zap++;
        switch(izbor){
                      case 1:dodaj(a);break;
                      case 2:ispis_bez_audi(a,br_zap);break;
                      case 3:{
                           cout << "Ispis automobila  marke Audi" << endl;
                           cout << "----------------------------" << endl;
                           int broj=100-br_zap;
                           audi(broj,br_zap);
                           }break;
                      case 4:break;
                      }
    }while(izbor!=4);
    system("pause");
    return 0;
}

Initial URL

                                

Initial Description

                                

Initial Title
Strukture podataka - Zadatak2

Initial Tags
podataka, c++

Initial Language
C++