Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- struct SkiLift {
- char ime[15];
- int maxBroj;
- int pusten;
- };
- struct SkiCentar {
- char imeCentar[150];
- char imeDrzava[150];
- int brojLiftovi;
- struct SkiLift liftovi[20];
- };
- void najgolemKapacitet(struct SkiCentar *sc, int n)
- {
- int i,j;
- int max = -9999;
- int indeksI, indeksJ;
- int zbir = 0;
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < sc[i].brojLiftovi; j++)
- {
- if(sc[i].liftovi[j].pusten == 1)
- {
- zbir+=sc[i].liftovi[j].maxBroj;
- }
- }
- if(zbir == max)
- {
- if(sc[i].brojLiftovi > sc[i - 1].brojLiftovi)
- {
- indeksI = i;
- }
- else
- {
- indeksI = i - 1;
- }
- }
- else if(zbir > max)
- {
- max = zbir;
- indeksI = i;
- indeksJ = j;
- }
- zbir = 0;
- }
- printf("%s\n",sc[indeksI].imeCentar);
- printf("%s\n",sc[indeksI].imeDrzava);
- printf("%d\n",max);
- }
- int main() {
- int n,i,j;
- scanf("%d", &n);
- struct SkiCentar sCentar[n];
- int maxBroj,pusten;
- for (i = 0; i < n; i++) {
- scanf("%s %s %d",&sCentar[i].imeCentar, &sCentar[i].imeDrzava,&sCentar[i].brojLiftovi);
- for(j = 0; j < sCentar[i].brojLiftovi; j++) {
- scanf("%s%d%d",&sCentar[i].liftovi[j].ime,&sCentar[i].liftovi[j].maxBroj,&sCentar[i].liftovi[j].pusten);
- }
- }
- najgolemKapacitet(sCentar,n);
- return 0;
- }
- VTORA
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Pica
- {
- private:
- char ime[15];
- int cena;
- char *sostojki;
- int popust;
- public:
- Pica():
- popust(0),sostojki(NULL),cena(0)
- {
- }
- Pica(char *name, int price, char *ingr, int discount):
- cena(price), popust(discount), sostojki(new char[strlen(ingr)+1])
- {
- strcpy(ime,name);
- strcpy(sostojki,ingr);
- }
- Pica(const Pica &o)
- {
- strcpy(ime,o.ime);
- cena = o.cena;
- popust = o.popust;
- sostojki = new char (strlen(o.sostojki));
- strcpy(sostojki,o.sostojki);
- }
- Pica &operator=(const Pica &pizza)
- {
- delete [] sostojki;
- sostojki = new char[strlen(pizza.sostojki)+1];
- strcpy(sostojki,pizza.sostojki);
- strcpy(ime,pizza.ime);
- popust = pizza.popust;
- cena = pizza.cena;
- return *this;
- }
- void pecati()
- {
- cout<<ime<<" "<<"-"<<" "<<sostojki<<","<<" "<<cena<<" ";
- }
- int getPopust()
- {
- return popust;
- }
- int getCena()
- {
- return cena;
- }
- int istiSe(Pica &p)
- {
- if(strcmp(this->sostojki, p.sostojki ) == 0)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- ~Pica()
- {
- delete [] sostojki;
- }
- };
- class Picerija
- {
- private:
- char ime[15];
- Pica *p;
- int brPici;
- public:
- Picerija()
- {
- }
- Picerija(char *name):
- brPici(0),p(NULL)
- {
- strcpy(ime,name);
- }
- void setIme(char *name)
- {
- strcpy(ime,name);
- }
- char *getIme()
- {
- return ime;
- }
- Picerija(const Picerija &o)
- {
- strcpy(ime,o.ime);
- brPici = o.brPici;
- p = new Pica[o.brPici];
- for(int i = 0; i < brPici;i++)
- {
- p[i] = o.p[i];
- }
- }
- Picerija &operator=(const Picerija &pic)
- {
- delete [] p;
- p = new Pica[pic.brPici + 1];
- for(int i = 0; i < brPici; i++)
- {
- p[i] = pic.p[i];
- }
- strcpy(ime,pic.ime);
- brPici = pic.brPici;
- return *this;
- }
- void dodadi(Pica &pz)
- {
- if(pz.getPopust() > 0&&pz.getPopust() < 100)
- {
- Pica *nova = new Pica[brPici+1];
- for(int i = 0; i < brPici; i++)
- {
- nova[i] = p[i];
- }
- if(brPici == 0)
- {
- nova[brPici] = pz;
- delete [] p;
- p = nova;
- brPici+=1;
- }
- else if(nova[brPici-1].istiSe(pz) != 1)
- {
- nova[brPici] = pz;
- delete [] p;
- p = nova;
- brPici+=1;
- }
- }
- }
- ~Picerija()
- {
- delete [] p;
- }
- void piciNaPromocija()
- {
- for(int i = 0; i < brPici; i++)
- {
- p[i].pecati();
- int popust;
- popust = p[i].getCena() - ((p[i].getCena() * p[i].getPopust())/100);
- cout<<popust<<endl;
- }
- }
- };
- int main () {
- int n;
- char ime[15];
- cin >> ime;
- cin >> n;
- Picerija p1(ime);
- for(int i = 0; i < n; i++){
- char imp[100];
- cin.get();
- cin.getline(imp,100);
- int cena;
- cin >> cena;
- char sostojki[100];
- cin.get();
- cin.getline(sostojki,100);
- int popust;
- cin >> popust;
- Pica p(imp,cena,sostojki,popust);
- p1.dodadi(p);
- }
- Picerija p2 = p1;
- cin >> ime;
- p2.setIme(ime);
- char imp[100];
- cin.get();
- cin.getline(imp,100);
- int cena;
- cin >> cena;
- char sostojki[100];
- cin.get();
- cin.getline(sostojki,100);
- int popust;
- cin >> popust;
- Pica p(imp,cena,sostojki,popust);
- p2.dodadi(p);
- cout<<p1.getIme()<<endl;
- cout<<"Pici na promocija:"<<endl;
- p1.piciNaPromocija();
- cout<<p2.getIme()<<endl;
- cout<<"Pici na promocija:"<<endl;
- p2.piciNaPromocija();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement