Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct datum{
- int dan,mjesec,godina;
- void Unos(int d,int m,int g){
- dan=d;
- mjesec=m;
- godina=g;
- }
- void Ispis(){
- cout<<dan<<"."<<mjesec<<"."<<godina<<endl;
- }
- };
- struct polozenipredmet
- {
- char naziv[20];
- datum dp;
- int ocjena;
- void unos(char *n,datum d, int o)
- {
- strcpy(naziv,n);
- dp=d;
- ocjena=o;
- }
- void ispis()
- {
- cout<<"Naziv: "<<naziv<<endl<<"Ocjena: "<<ocjena<<endl;
- dp.Ispis();
- }
- };
- struct student
- {
- int bri;
- char imeprezime[20];
- datum r;
- polozenipredmet *pr;
- int tpol;
- int maxp;
- void unos(int index,char *ip,datum dr)
- {
- bri=index;
- strcpy(imeprezime,ip);
- r=dr;
- }
- bool dodajpolozeni(char *n,datum d,int o)
- {
- if(tpol==0)
- {
- tpol++;
- pr[0].unos(n,d,o);
- }
- else
- {
- for(int i=1;i<=tpol;i++)
- {
- if(strcmp(pr[i].naziv,n)!=0)
- return false;
- }
- pr[tpol+1].unos(n,d,o);
- tpol++;
- return true;
- }
- }
- int uklonipredmet(datum d)
- {
- int uk=0;
- bool ukl=false;
- for(int i=0;i<tpol;i++)
- {
- if(pr[i].dp.dan==d.dan && pr[i].dp.mjesec==d.mjesec && pr[i].dp.godina==d.godina)
- {
- strcpy(pr[i].naziv,pr[i+1].naziv);
- pr[i].dp=pr[i+1].dp;
- pr[i].ocjena=pr[i+1].ocjena;
- tpol--;
- uk++;
- ukl=true;
- }
- if (ukl)
- {
- strcpy(pr[i].naziv,pr[i+1].naziv);
- pr[i].dp=pr[i+1].dp;
- pr[i].ocjena=pr[i+1].ocjena;
- }
- }
- return uk;
- }
- void ispis()
- {
- cout<<"\nIme i prezime: "<<imeprezime<<endl<<"Broj indexa: "<<bri<<endl<<"Datum rodjenja: "<<r.dan<<"."<<r.mjesec<<"."<<r.godina<<endl;
- }};
- void main()
- {
- student s1;
- s1.r.Unos(29,34,2345);
- s1.tpol=0;
- s1.maxp=40;
- s1.unos(3245,"rijad spahic",s1.r);
- s1.pr=new polozenipredmet[s1.maxp];
- datum x,y,z;
- x.dan=1;
- x.mjesec=3;
- x.godina=2012;
- y.dan=5;
- y.mjesec=2;
- y.godina=2013;
- z.dan=26;
- z.mjesec=11;
- z.godina=2010;
- if(s1.dodajpolozeni("programiranje",x,7)==true)
- cout<<"Greska, predmet vec postoji!"<<endl;
- else
- cout<<"Uspjesno dodat"<<endl;
- if(s1.dodajpolozeni("asp",y,9)==true)
- cout<<"Greska, predmet vec postoji!"<<endl;
- else
- cout<<"Uspjesno dodat"<<endl;
- if(s1.dodajpolozeni("aks",z,5)==true)
- cout<<"Greska, predmet vec postoji!"<<endl;
- else
- cout<<"Uspjesno dodat"<<endl;
- s1.ispis();
- for(int i=0;i<s1.tpol;i++)
- {
- s1.pr[i].ispis();
- cout<<endl;
- }
- cout<<s1.uklonipredmet(x);
- system ("pause>0");
- }
Advertisement
Add Comment
Please, Sign In to add comment