Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- /*
- +
- -
- ++
- --
- +=
- -=
- >
- <
- ==
- >>
- <<
- >=
- <=
- */
- class PlDrustvo{
- private:
- char *ime;
- int brturi;
- int brclenovi;
- public:
- PlDrustvo(){
- ime=new char[0];
- brturi=0;
- brclenovi=0;
- }
- PlDrustvo(char *ime1,int brturi1, int brclenovi1){
- ime=new char[strlen(ime1)+1];
- strcpy(ime,ime1);
- brturi=brturi1;
- brclenovi=brclenovi1;
- }
- PlDrustvo(const PlDrustvo &p){
- ime=new char[strlen(p.ime)+1];
- strcpy(ime,p.ime);
- brturi=p.brturi;
- brclenovi=p.brclenovi;
- }
- PlDrustvo operator =(const PlDrustvo &p){
- if(this!=&p){
- ime=new char[strlen(p.ime)+1];
- strcpy(ime,p.ime);
- brturi=p.brturi;
- brclenovi=p.brclenovi;
- }
- return *this;
- }
- ~PlDrustvo(){
- delete[] ime;
- }
- PlDrustvo operator+(const PlDrustvo &p){
- if(brclenovi>p.brclenovi){
- PlDrustvo novoDrustvo(ime,brturi,brclenovi+p.brclenovi);
- return novoDrustvo;
- }else if(brclenovi<p.brclenovi){
- PlDrustvo novoDrustvo(p.ime,p.brturi,brclenovi+p.brclenovi);
- return novoDrustvo;
- }
- }
- bool operator >(int vrednost){
- if(brclenovi>vrednost){
- return true;
- }else{
- return false;
- }
- }
- bool operator <(const PlDrustvo &p){
- if(brclenovi<p.brclenovi){
- return true;
- }else{
- return false;
- }
- }
- friend ostream& operator <<(ostream &o,const PlDrustvo &p){
- o<<p.ime<<" "<<p.brturi<<" "<<p.brclenovi<<endl;
- return o;
- }
- int getClenovi(){
- return brclenovi;
- }
- };
- void najmnoguClenovi(PlDrustvo *pd,int n){
- int maxClenovi=-99999;
- int cuvajIndeks;
- for(int i=0;i<n;i++){
- if(pd[i]>maxClenovi){
- maxClenovi=pd[i].getClenovi();
- cuvajIndeks=i;
- }
- }
- cout<<pd[cuvajIndeks];
- }
- int main()
- {
- PlDrustvo drustva[3];
- PlDrustvo pl;
- for (int i=0;i<3;i++)
- {
- char ime[100];
- int brTuri;
- int brClenovi;
- cin>>ime;
- cin>>brTuri;
- cin>>brClenovi;
- PlDrustvo p(ime,brTuri,brClenovi);
- drustva[i] = p;
- }
- pl = (drustva[0] + drustva[1]);
- cout<<pl;
- najmnoguClenovi(drustva, 3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement