Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ne znam zasto mi vrakja greski za operatorot,se uspav i posle se ke ti dopratam
- #include <iostream>
- #include <cstring>
- using namespace std;
- class WebPage
- {
- private:
- char url[100];
- char *sodrzina;
- public:
- WebPage(char *url="",char *sodrzina="")
- {
- strcpy(this->url,url);
- this->sodrzina=new char[strlen(sodrzina)+1];
- strcpy(this->sodrzina,sodrzina);
- }
- WebPage(const WebPage &wp)
- {
- strcpy(this->url,wp.url);
- this->sodrzina=new char[strlen(wp.sodrzina)+1];
- strcpy(this->sodrzina,wp.sodrzina);
- }
- WebPage &operator =( WebPage &wp)
- { if(this!=&wp) {
- strcpy(this->url,wp.url);
- delete [] this->sodrzina;
- this->sodrzina= new char[strlen(wp.sodrzina)+1];
- strcpy(this->sodrzina,wp.sodrzina);
- }
- return *this;
- }
- char *getUrl()
- {
- return this->url;
- }
- void setUrl(char *url)
- {
- strcpy(this->url,url);
- }
- char *getSodrzina ()
- {
- return this->sodrzina;
- }
- void *setSodrzina (char *sodrzina)
- {
- delete [] this->sodrzina;
- this->sodrzina=new char [strlen(sodrzina)+1];
- strcpy(this->sodrzina,sodrzina);
- }
- bool proverka(WebPage wp)
- {
- if(strcmp(this->url,wp.url)==0 && strcmp(this->sodrzina,wp.sodrzina)==0)
- return true;
- else
- return false;
- }
- void Pecati()
- {
- cout<<url<<endl;
- cout<<sodrzina<<endl;
- }
- };
- class WebServer
- {
- private:
- char ime[30];
- WebPage wps;
- int n;
- public:
- WebServer(char *ime="", WebPage *wps=0,int n=0)
- {
- strcpy(this->ime,ime);
- this->wps= new WebPage[n];
- for(int i=0;i<n;i++)
- {
- this->wps[i]=WebPage(wps[i]);
- }
- }
- WebServer(const WebServer &ws)
- {
- strcpy(this->ime,ws.ime);
- this->wps=new WebPage[ws.n];
- for(int i=0;i<n;i++)
- {
- this->wps[i]=WebPage(ws.wps[i]);
- }
- this->n=ws.n;
- }
- WebServer &operator = (WebServer &ws)
- { if(this!=&ws)
- {
- strcpy(this->ime,wp.ime);
- delete [] this->wps;
- this->wps=new WebPage[ws.n];
- for(int i=0;i<n;i++)
- {
- this->wps[i]=ws.n;
- }
- this->n=ws.n;
- }
- }
- int getN ()
- {
- return this->n;
- }
- void setN(int n)
- {
- this->n=n;
- }
- char *getIme ()
- {
- return this->ime;
- }
- void setIme(char *ime)
- {
- strcpy(this->ime,ime);
- }
- WebPage *getWps ()
- {
- return this->wps;
- }
- void setWps(WebPage *wps,int n)
- {
- delete [] this->wps;
- for(int i=0;i<n;i++)
- {
- this->wps[i].setUrl(wsp[i].getUrl());
- this->wps[i].getSodrzina(wps[i].getSodrzina());
- }
- }
- void Dodadi(WebServer wp)
- {
- WebPage *temp;
- temp=new WebPage[this->n];
- for( int i=0;i<n;i++)
- {
- temp[i]=WebPage(this->wps[i]);
- }
- delete [] this->wps;
- this->wps=WebPage[this->n+1];
- for(int i=0;i<n;i++)
- {
- this->wps[i]=WebPage(temp[i]);
- }
- delete [] temp;
- this->wps[n]=WebPage(wp);
- n++;
- }
- void Izbrisi(WebServer wp)
- {
- WebPage *temp;
- int j=0;
- temp=new WebPage[this->n-1];
- for( int i=0;i<n;i++)
- { if(this->wps[i].proverka(wp))
- continue;
- temp[j]=WebPage(this->wps[i]);
- j++;
- }
- delete [] this->wps;
- this->wps=new WebPage[j];
- for(int i=0;i<n;i++)
- {
- this->wps[i]=WebPage(temp[j]);
- }
- delete [] temp;
- n--;
- }
- void sortAlpha()
- {
- for(int i=0;i<n;i++)
- { for(int j=i+1;j<this->i+1;j++)
- {
- if(strcmp(wps[i].getUrl().wps[j].getUrl()>0)
- wps t=this->wps[i];
- wps[i]=wps[j];
- wps[j]=t;
- }
- }
- }
- void sortLen()
- {
- for(i=0;i<this->n;i++)
- {
- for(j=i+1;j<this->n;j++)
- {
- if(strlen(wps[i].getUrl())>strlen(wps[j].getUrl()))
- {
- WebPage t=wps[i];
- wps[i]=wps[j];
- wps[j]=t;
- }
- }
- }
- }
- void Pecatistranicisourlnad(int n)
- {
- for(int i=0;i<n;i++)
- {
- if(strlen(this->wps[i].getUrl())>=n)
- {
- this->wps[i].pecati();
- }
- }
- }
- };
- void pecati(WebPage *wps,int n)
- {
- for(i=0;i<n;i++)
- {
- wps[i].Pecati();
- }
- }
- int main()
- {
- int n;
- char url[100], sodrzina[100], ime[100];
- cout << "Vnesete broj na WebStranici vo serverot: ";
- cin >> n;
- WebPage stranici[n];
- for(int i=0;i<n;i++)
- {
- cout << endl << "Vnesete URL za " << i << "-ta stranica: ";
- cin >> url;
- cout << endl << "Vnesete SODRZINA za " << i << "-ta stranica: ";
- cin >> sodrzina;
- stranici[i] = WebPage(url,sodrzina);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment