Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- struct info
- {
- int dan,mjesec,godina;
- info *sljedeci;
- };
- info *pocetak,*kraj;
- info *noviInfo();
- void dodajNaPocetak(info *novi);
- void dodajNaKraj(info *novi);
- void ispis();
- void meni();
- void ispisN(int broj);
- int main()
- {
- pocetak=NULL;
- kraj=NULL;
- int n=0,broj;
- info *novi;
- while(n!=9)
- {
- meni();
- cin>>n;
- system("cls");
- switch(n)
- {
- case 1:
- novi=noviInfo();
- dodajNaPocetak(novi);
- break;
- case 2:
- novi=noviInfo();
- dodajNaKraj(novi);
- break;
- case 3:
- ispis();
- break;
- case 4:
- cout<<"Unesite broj mjeseca:->";
- cin>>broj;
- ispisN(broj);
- break;
- case 9:
- cout<<"Program se zavrsava."<<endl;
- break;
- default:
- cout<<"Ponovite odabir."<<endl;
- break;
- }
- }
- return EXIT_SUCCESS;
- }
- info *noviInfo()
- {
- info *temp=new info;
- cout<<"Dan:->"; cin>>temp->dan;
- cout<<"Mjesec:->"; cin>>temp->mjesec;
- cout<<"Godina:->"; cin>>temp->godina;
- temp->sljedeci=NULL;
- return temp;
- }
- void dodajNaPocetak(info *novi)
- {
- if(pocetak==NULL)
- {
- pocetak=novi;
- kraj=novi;
- }
- else
- {
- novi->sljedeci=pocetak;
- pocetak=novi;
- }
- }
- void dodajNaKraj(info *novi)
- {
- if(pocetak==NULL)
- {
- pocetak=novi;
- kraj=novi;
- }
- else
- {
- kraj->sljedeci=novi;
- kraj=novi;
- }
- }
- void ispis()
- {
- info *temp=pocetak;
- while(temp!=NULL)
- {
- cout<<temp->dan;
- cout<<"."; cout<<temp->mjesec;
- cout<<"."; cout<<temp->godina<<endl;
- temp=temp->sljedeci;
- }
- }
- void ispisN(int broj)
- {
- info *temp=pocetak;
- while(temp!=NULL)
- {
- if(temp->mjesec==broj){
- cout<<temp->dan;
- cout<<"."; cout<<temp->mjesec;
- cout<<"."; cout<<temp->godina<<endl;
- }
- temp=temp->sljedeci;
- }
- }
- void meni(){
- cout<<"1*-Dodavanje na pocetak"<<endl;
- cout<<"2*-DOdavanje na kraj"<<endl;
- cout<<"3*-Ispis iz liste"<<endl;
- cout<<"4*-Ispis datuma sa odredjenim mjesecom."<<endl;
- cout<<"9*-EXIT"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement