diff --git a/07OK.cpp b/07OK.cpp index 5755d42..ed86d0b 100644 --- a/07OK.cpp +++ b/07OK.cpp @@ -1,168 +1,168 @@ -#include -#include -#include - -using namespace std; - -class Person -{ - char* name; -public: - friend class Couple; - friend ostream& operator<<(ostream& str, const Person& os) - { - //str << "Person : " << os.name << endl; - str << os.name; - }; - - Person(const char* n) - { - //name = (char*) n; - - /* Jak dluga jest tablica? */ - int licznik, licznik1; - const char *glowicar; - char* glowicaw; - - glowicar = n; - //cout << "n : " << n << endl; - //cout << "glowicar : " << glowicar << endl; - - licznik = 0; - while( *glowicar != 0) - { - ++glowicar; - ++licznik; - } - //cout << "n : " << n << endl; - //cout << "glowicar : " << glowicar << endl; - - /* Kopiowanie. */ - glowicar = n; - //cout << "aa:" << (int)glowicar << endl; - name = (char*)malloc( (licznik + 1)*sizeof(char) ); - glowicaw = name; - - for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) - { - *glowicaw = (char)(*glowicar); - ++glowicaw; - ++glowicar; - } - - /* Wydruk testowy. */ - cout << "test : " << (int) name << endl ; - }; - Person(const Person& os) - { - //name = os.name; - - /* Jak dluga jest tablica? */ - int licznik, licznik1; - const char* glowicar; - char* glowicaw; - - glowicar = os.name; - licznik = 0; - while( *glowicar != 0) - { - ++glowicar; - ++licznik; - } - - /* Kopiowanie. */ - glowicar = os.name; - name = (char*)malloc( (licznik + 1)*sizeof(char) ); - glowicaw = name; - for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) - { - *glowicaw = (char)(*glowicar); - ++glowicaw; - ++glowicar; - } - /* Wydruk testowy. */ - cout << "test2 : " << (int) name << endl ; - - }; - - Person& operator=(const Person& os) - { - //free(this->name); - this->name=os.name; - - return *this; - }; - - ~Person() - { - cout << "Desktruktor ~Person" << endl; - free(name); - }; -}; - -class Couple -{ - Person *husb, *wife; -public: - friend ostream& operator<<(ostream& str, const Couple& p) - { - str << "He: " << *p.husb << " , She: " << *p.wife << endl; - }; - Couple(const char* m, const char* z) - { - husb = new Person(m); - wife = new Person(z); - }; - Couple(const Couple& p) - { - husb = new Person( *p.husb ); - wife = new Person( *p.wife ); - }; - Couple& operator=(const Couple& p) - { - //free(this->husb->name); - //free(this->wife->name); - //free(this->husb); - //free(this->wife); - - this->husb = new Person(*p.husb); - this->wife = new Person(*p.wife); - - return *this; - }; - ~Couple() - { - cout << "Desktruktor ~Couple" << endl; - free(husb->name); - free(wife->name); - - free(husb); - free(wife); - }; -}; - -int main(void) -{ - Person person1("Mariusz"); - Person person2(person1); - - cout << person1 << endl; - cout << person2 << endl; - - Person *person_c1 = new Person("John"); - Person person_c2("Bert"); - *person_c1 = person_c2; - Person person_c3(*person_c1); - delete person_c1; - cout << person_c3 << endl; - - Couple *c1 = new Couple("John","Sue"); - Couple c2("Bert","Elsa"); - *c1 = c2; - Couple c3(*c1); - delete c1; - cout << c3 << endl; //He: Bert, She: Elsa - - //system("Pause"); - return 0; -} +#include +#include +#include + +using namespace std; + +class Person +{ + char* name; +public: + friend class Couple; + friend ostream& operator<<(ostream& str, const Person& os) + { + //str << "Person : " << os.name << endl; + str << os.name; + }; + + Person(const char* n) + { + //name = (char*) n; + + /* Jak dluga jest tablica? */ + int licznik, licznik1; + const char *glowicar; + char* glowicaw; + + glowicar = n; + cout << "n : " << n << endl; + cout << "glowicar : " << glowicar << endl; + + licznik = 0; + while( *glowicar != 0) + { + ++glowicar; + ++licznik; + } + cout << "n : " << n << endl; + cout << "glowicar : " << glowicar << endl; + + /* Kopiowanie. */ + glowicar = n; + cout << "aa:" << (int)glowicar << endl; + name = (char*)malloc( (licznik + 1)*sizeof(char) ); + glowicaw = name; + + for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) + { + *glowicaw = (char)(*glowicar); + ++glowicaw; + ++glowicar; + } + + /* Wydruk testowy. */ + cout << "test : " << (int) name << endl ; + }; + Person(const Person& os) + { + //name = os.name; + + /* Jak dluga jest tablica? */ + int licznik, licznik1; + const char* glowicar; + char* glowicaw; + + glowicar = os.name; + licznik = 0; + while( *glowicar != 0) + { + ++glowicar; + ++licznik; + } + + /* Kopiowanie. */ + glowicar = os.name; + name = (char*)malloc( (licznik + 1)*sizeof(char) ); + glowicaw = name; + for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) + { + *glowicaw = (char)(*glowicar); + ++glowicaw; + ++glowicar; + } + /* Wydruk testowy. */ + cout << "test2 : " << (int) name << endl ; + + }; + + Person& operator=(const Person& os) + { + //free(this->name); + this->name=os.name; + + return *this; + }; + + ~Person() + { + //cout << "Desktruktor ~Person" << endl; + free(name); + }; +}; + +class Couple +{ + Person *husb, *wife; +public: + friend ostream& operator<<(ostream& str, const Couple& p) + { + str << "He: " << *p.husb << " , She: " << *p.wife << endl; + }; + Couple(const char* m, const char* z) + { + husb = new Person(m); + wife = new Person(z); + }; + Couple(const Couple& p) + { + husb = new Person( *p.husb ); + wife = new Person( *p.wife ); + }; + Couple& operator=(const Couple& p) + { + //free(this->husb->name); + //free(this->wife->name); + //free(this->husb); + //free(this->wife); + + this->husb = new Person(*p.husb); + this->wife = new Person(*p.wife); + + return *this; + }; + ~Couple() + { + //cout << "Desktruktor ~Couple" << endl; + free(husb->name); + free(wife->name); + + free(husb); + free(wife); + }; +}; + +int main(void) +{ + Person person1("Mariusz"); + Person person2(person1); + + cout << person1 << endl; + cout << person2 << endl; + + Person *person_c1 = new Person("John"); + Person person_c2("Bert"); + *person_c1 = person_c2; + Person person_c3(*person_c1); + delete person_c1; + cout << person_c3 << endl; + + Couple *c1 = new Couple("John","Sue"); + Couple c2("Bert","Elsa"); + *c1 = c2; + Couple c3(*c1); + delete c1; + cout << c3 << endl; //He: Bert, She: Elsa + + //system("Pause"); + return 0; +} diff --git a/README b/README deleted file mode 100644 index 0eeb3dd..0000000 --- a/README +++ /dev/null @@ -1,4 +0,0 @@ -My simply programs written in C++ in WUT. - -Best regards, -Mariusz Zbikowski diff --git a/Zadanie6/Szablon.cpp b/Zadanie6/Szablon.cpp deleted file mode 100644 index 52164c9..0000000 --- a/Zadanie6/Szablon.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include - -using namespace std; - -/***************************************/ - -enum Banks {PKO, BGZ, BRE, BPH}; - -/***************************************/ - -struct Account -{ - Banks bank; - int balance; -}; - -struct Person -{ - char name[20]; - Account account; -}; - -struct Couple -{ - Person he; - Person she; -}; - -/***************************************/ - -Couple* bestClient(Couple* cpls, int size, Banks bank) -{ - -} - -int main() -{ - Couple cpls[]={ - - }; - - Couple *p = bestClient(cpls, 4, BGZ); - - //system("Pause"); - return 0; -} diff --git a/Zadanie6/Zadanie6INACZEJ.cpp b/Zadanie6/Zadanie6INACZEJ.cpp deleted file mode 100644 index 17f3d2a..0000000 --- a/Zadanie6/Zadanie6INACZEJ.cpp +++ /dev/null @@ -1,172 +0,0 @@ -#include -#include - -using namespace std; - -/***************************************/ - -enum Banks {PKO, BGZ, BRE, BPH}; - -/***************************************/ - -struct Account -{ - Banks bank; - int balance; -}; - -struct Person -{ - char name[20]; - Account account; -}; - -struct Couple -{ - Person he; - Person she; -}; - -/***************************************/ -void WypiszTabliceChar(char *tablica, int size) -{ - int licznik; - - cout << "\n"; - for(licznik = 0; licznik < size; ++licznik) - { - cout << "Pozycja #" << licznik - << " : " << tablica[licznik] - << " : " << (int)tablica[licznik] - << "\n"; - } -} -/***************************************/ -void WypiszPare(Couple* para) -{ - cout << (para->he).name << " & " - << (para->she).name << " : " - << (para->he).account.balance + (para->she).account.balance << "\n"; -} -/***************************************/ - -Couple* bestClient(Couple* cpls, int size, Banks bank) -{ - int licznik; - int findstatus, licznikmax, sumamax; - - findstatus = 0; - for(licznik = 0; licznik < size; ++licznik) - { - if( (cpls[licznik].he.account.bank == bank) || (cpls[licznik].she.account.bank == bank) ) - { - if(findstatus == 0) - { - licznikmax = licznik; - sumamax = cpls[licznik].he.account.balance + cpls[licznik].she.account.balance; - findstatus = 1; - } - else if ((findstatus == 1) && (sumamax < cpls[licznik].he.account.balance + cpls[licznik].she.account.balance) ) - { - licznikmax = licznik; - sumamax = cpls[licznik].he.account.balance + cpls[licznik].she.account.balance; - } - - } - } - - //cout << "Wynik z wewnatrz : " << cpls[licznikmax].he.account.balance << "\n"; - - if(findstatus == 0) - { - return NULL; - } - else - { - return (&(cpls[licznikmax])); - } -} - -/***************************************/ -int main() -{ - Couple cpls[4]; - Couple *wynik; - - cpls[0].he.name[0] = 'J'; - cpls[0].he.name[1] = 'o'; - cpls[0].he.name[2] = 'h'; - cpls[0].he.name[3] = 'n'; - cpls[0].he.name[4] = 'y'; - cpls[0].he.name[5] = NULL; - cpls[0].he.account.bank = PKO; - cpls[0].he.account.balance = 1100; - - cpls[0].she.name[0] = 'M'; - cpls[0].she.name[1] = 'a'; - cpls[0].she.name[2] = 'r'; - cpls[0].she.name[3] = 'y'; - cpls[0].she.name[4] = NULL; - cpls[0].she.account.bank = BGZ; - cpls[0].she.account.balance = 1500; - - cpls[1].he.name[0] = 'P'; - cpls[1].he.name[1] = 'e'; - cpls[1].he.name[2] = 't'; - cpls[1].he.name[3] = 'e'; - cpls[1].he.name[4] = 'r'; - cpls[1].he.name[5] = NULL; - cpls[1].he.account.bank = BGZ; - cpls[1].he.account.balance = 1400; - - cpls[1].she.name[0] = 'S'; - cpls[1].she.name[1] = 'u'; - cpls[1].she.name[2] = 'z'; - cpls[1].she.name[3] = 'y'; - cpls[1].she.name[4] = NULL; - cpls[1].she.account.bank = BRE; - cpls[1].she.account.balance = 1300; - - cpls[2].he.name[0] = 'K'; - cpls[2].he.name[1] = 'e'; - cpls[2].he.name[2] = 'v'; - cpls[2].he.name[3] = 'i'; - cpls[2].he.name[4] = 'n'; - cpls[2].he.name[5] = NULL; - cpls[2].he.account.bank = PKO; - cpls[2].he.account.balance = 1600; - - cpls[2].she.name[0] = 'K'; - cpls[2].she.name[1] = 'a'; - cpls[2].she.name[2] = 't'; - cpls[2].she.name[3] = 'y'; - cpls[2].she.name[4] = NULL; - cpls[2].she.account.bank = BPH; - cpls[2].she.account.balance = 1500; - - cpls[3].he.name[0] = 'K'; - cpls[3].he.name[1] = 'e'; - cpls[3].he.name[2] = 'n'; - cpls[3].he.name[3] = 'n'; - cpls[3].he.name[4] = 'y'; - cpls[3].he.name[5] = NULL; - cpls[3].he.account.bank = BPH; - cpls[3].he.account.balance = 1800; - - cpls[3].she.name[0] = 'L'; - cpls[3].she.name[1] = 'u'; - cpls[3].she.name[2] = 'c'; - cpls[3].she.name[3] = 'y'; - cpls[3].she.name[4] = NULL; - cpls[3].she.account.bank = BRE; - cpls[3].she.account.balance = 1700; - - wynik = bestClient(cpls, 4, BGZ); - WypiszPare(wynik); - - //cout << "Wynik z zewnatrz " << (wynik->he).account.balance << "\n"; - //WypiszTabliceChar(wynik->she.name, 20); - - - //system("pause"); -} diff --git a/Zadanie6/Zadanie6MOJE.cpp b/Zadanie6/Zadanie6MOJE.cpp deleted file mode 100644 index e278461..0000000 --- a/Zadanie6/Zadanie6MOJE.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include - -using namespace std; - -/***************************************/ - -enum Banks {PKO, BGZ, BRE, BPH}; - -/***************************************/ - -struct Account -{ - Banks bank; - int balance; -}; - -struct Person -{ - char name[20]; - Account account; -}; - -struct Couple -{ - Person he; - Person she; -}; - -/***************************************/ - -Couple* bestClient(Couple* cpls, int size, Banks bank) -{ - int counter_max; - int max_balance; - bool mark; - -if (size == 0) return NULL; -else -{ - for(int counter = 0; counter < size; ++counter) - { - if( (cpls[counter].he.account.bank == bank) || (cpls[counter].she.account.bank == bank) ) - { - if(mark==0) - { - counter_max=counter; - max_balance=cpls[counter].he.account.balance + cpls[counter].she.account.balance; - mark = 1; - } - if((mark == 1) && (max_balancehe).name << " and " << (p->she).name - << " : " << (p->he).account.balance + (p->she).account.balance - << endl; - } -} - -int main() -{ - Couple cpls[4]; - Couple *p; - - /**************JOHNY********************/ - cpls[0].he.name[0] = 'J'; - cpls[0].he.name[1] = 'o'; - cpls[0].he.name[2] = 'h'; - cpls[0].he.name[3] = 'n'; - cpls[0].he.name[4] = 'y'; - cpls[0].he.name[5] = (char)NULL; - cpls[0].he.account.bank = PKO; - cpls[0].he.account.balance = 1100; - /**************MARY********************/ - cpls[0].she.name[0] = 'M'; - cpls[0].she.name[1] = 'a'; - cpls[0].she.name[2] = 'r'; - cpls[0].she.name[3] = 'y'; - cpls[0].she.name[4] = (char)NULL; - cpls[0].she.account.bank = BGZ; - cpls[0].she.account.balance = 1500; - /*--------------------------------------------*/ - /**************PETER********************/ - cpls[1].he.name[0] = 'P'; - cpls[1].he.name[1] = 'e'; - cpls[1].he.name[2] = 't'; - cpls[1].he.name[3] = 'e'; - cpls[1].he.name[4] = 'r'; - cpls[1].he.name[5] = (char) NULL; - cpls[1].he.account.bank = BGZ; - cpls[1].he.account.balance = 1400; - /**************SUZY********************/ - cpls[1].she.name[0] = 'S'; - cpls[1].she.name[1] = 'u'; - cpls[1].she.name[2] = 'z'; - cpls[1].she.name[3] = 'y'; - cpls[1].she.name[4] = (char) NULL; - cpls[1].she.account.bank = BRE; - cpls[1].she.account.balance = 1300; - /*--------------------------------------------*/ - /**************KEVIN********************/ - cpls[2].he.name[0] = 'K'; - cpls[2].he.name[1] = 'e'; - cpls[2].he.name[2] = 'v'; - cpls[2].he.name[3] = 'i'; - cpls[2].he.name[4] = 'n'; - cpls[2].he.name[5] = (char) NULL; - cpls[2].he.account.bank = PKO; - cpls[2].he.account.balance = 1600; - /**************KATY********************/ - cpls[2].she.name[0] = 'K'; - cpls[2].she.name[1] = 'a'; - cpls[2].she.name[2] = 't'; - cpls[2].she.name[3] = 'y'; - cpls[2].she.name[4] = (char) NULL; - cpls[2].she.account.bank = BPH; - cpls[2].she.account.balance = 1500; - /*--------------------------------------------*/ - /**************KENNY********************/ - cpls[3].he.name[0] = 'K'; - cpls[3].he.name[1] = 'e'; - cpls[3].he.name[2] = 'n'; - cpls[3].he.name[3] = 'n'; - cpls[3].he.name[4] = 'y'; - cpls[3].he.name[5] = (char) NULL; - cpls[3].he.account.bank = BPH; - cpls[3].he.account.balance = 1800; - /**************LUCY********************/ - cpls[3].she.name[0] = 'L'; - cpls[3].she.name[1] = 'u'; - cpls[3].she.name[2] = 'c'; - cpls[3].she.name[3] = 'y'; - cpls[3].she.name[4] = (char) NULL; - cpls[3].she.account.bank = BRE; - cpls[3].she.account.balance = 1700; - /*--------------------------------------------*/ - - p = bestClient(cpls, 4, BGZ); - ShowCouple(p); - - //system("pause"); - return 0; -} diff --git a/Zadanie6/Zadanie6Najprosciej.cpp b/Zadanie6/Zadanie6Najprosciej.cpp deleted file mode 100644 index c4806c9..0000000 --- a/Zadanie6/Zadanie6Najprosciej.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include - -using namespace std; - -/***************************************/ - -enum Banks {PKO, BGZ, BRE, BPH, ING}; - -/***************************************/ - -struct Account -{ - Banks bank; - int balance; -}; - -struct Person -{ - char name[20]; - Account account; -}; - -struct Couple -{ - Person he; - Person she; -}; - -/***************************************/ - -Couple* bestClient(Couple* cpls, int size, Banks bank) -{ - int counter_max; - int max_balance; - bool mark;//domyslnie mark=false - -if (size == 0) return NULL; -else -{ - for(int counter = 0; counter < size; ++counter) - { - if( (cpls[counter].he.account.bank == bank) || (cpls[counter].she.account.bank == bank) ) - { - if(mark==0)//za pierwszym razem - { - counter_max=counter; - max_balance=cpls[counter].he.account.balance + cpls[counter].she.account.balance; - - } - //za kazdym nastepnym razem - if((mark !=0) && (max_balancehe.name << " and " << p->she.name << " : " << p->he.account.balance + p->she.account.balance << endl; - } -} - -int main() -{ - Couple cpls[]={ {{"Johny",{PKO,1100}},{"Mary",{BGZ,1500} }}, - {{"Peter",{BGZ,1400}},{"Suzy",{BRE,1300} }}, - {{"Kevin",{PKO,1600}},{"Katy",{BPH,1500} }}, - {{"Johny",{BPH,1800}},{"Mary",{BRE,1700} }} - }; - - Couple *p = bestClient(cpls, 4, BGZ); - ShowCouple(p); - p = bestClient(cpls, 4, ING); - ShowCouple(p); - - //system("pause"); - return 0; -} diff --git a/Zadanie6/Zadanie_06.pdf b/Zadanie6/Zadanie_06.pdf deleted file mode 100644 index 141a761..0000000 Binary files a/Zadanie6/Zadanie_06.pdf and /dev/null differ diff --git a/Zadanie6/makefile b/Zadanie6/makefile deleted file mode 100644 index 746eebe..0000000 --- a/Zadanie6/makefile +++ /dev/null @@ -1,2 +0,0 @@ -clean: - rm -f *.out diff --git a/Zadanie7/06PrawieDobrze.cpp b/Zadanie7/06PrawieDobrze.cpp deleted file mode 100644 index 71b1854..0000000 --- a/Zadanie7/06PrawieDobrze.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include - -using namespace std; - -class Person -{ - char* name; -public: - friend class Couple; - friend ostream& operator<<(ostream& str, const Person& os) - { - //str << "Person : " << os.name << endl; - str << os.name; - }; - - Person(const char* n) - { - name = (char*) n; - cout << "test = " <<(int) name << endl; - }; - Person(const Person& os) - { - name = os.name; - cout << "test2 = " <<(int) name << endl; - }; - - Person& operator=(const Person& os) - { - //free(this->name); - this->name=os.name; - - return *this; - }; - - ~Person() - { - //cout << "Desktruktor ~Person" << endl; - free(name); - }; -}; - -class Couple -{ - Person *husb, *wife; -public: - friend ostream& operator<<(ostream& str, const Couple& p) - { - str << "He: " << *p.husb << " , She: " << *p.wife << endl; - }; - Couple(const char* m, const char* z) - { - husb = new Person(m); - wife = new Person(z); - }; - Couple(const Couple& p) - { - husb = new Person( *p.husb ); - wife = new Person( *p.wife ); - }; - Couple& operator=(const Couple& p) - { - //free(this->husb->name); - //free(this->wife->name); - //free(this->husb); - //free(this->wife); - - this->husb = new Person(*p.husb); - this->wife = new Person(*p.wife); - - return *this; - }; - ~Couple() - { - //cout << "Desktruktor ~Couple" << endl; - free(husb->name); - free(wife->name); - - free(husb); - free(wife); - }; -}; - -int main(void) -{ - Person person1("Mariusz"); - Person person2(person1); - - cout << person1 << endl; - cout << person2 << endl; - - Person *person_c1 = new Person("John"); - Person person_c2("Bert"); - *person_c1 = person_c2; - Person person_c3(*person_c1); - delete person_c1; - cout << person_c3 << endl; - - Couple *c1 = new Couple("John","Sue"); - Couple c2("Bert","Elsa"); - *c1 = c2; - Couple c3(*c1); - delete c1; - cout << c3 << endl; //He: Bert, She: Elsa - - //system("Pause"); - return 0; -} diff --git a/Zadanie7/07OK.cpp b/Zadanie7/07OK.cpp deleted file mode 100644 index 1a1fc3c..0000000 --- a/Zadanie7/07OK.cpp +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include -#include - -using namespace std; - -class Person -{ - char* name; -public: - friend class Couple; - friend ostream& operator<<(ostream& str, const Person& os) - { - //str << "Person : " << os.name << endl; - str << os.name; - }; - - Person(const char* n) - { - //name = (char*) n; - - /* Jak dluga jest tablica? */ - int licznik, licznik1; - const char *glowicar; - char* glowicaw; - - glowicar = n; - licznik = 0; - while( *glowicar != 0) - { - ++glowicar; - ++licznik; - } - - /* Kopiowanie. */ - glowicar = n; - name = (char*)malloc( (licznik + 1)*sizeof(char) ); - glowicaw = name; - for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) - { - *glowicaw = (char)(*glowicar); - ++glowicaw; - ++glowicar; - } - - /* Wydruk testowy. */ - cout << "test : " << (int) name << endl ; - }; - Person(const Person& os) - { - //name = os.name; - - /* Jak dluga jest tablica? */ - int licznik, licznik1; - char *glowicar; - char* glowicaw; - - glowicar = os.name; - licznik = 0; - while( *glowicar != 0) - { - ++glowicar; - ++licznik; - } - - /* Kopiowanie. */ - glowicar = os.name; - name = (char*)malloc( (licznik + 1)*sizeof(char) ); - glowicaw = name; - for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) - { - *glowicaw = (char)(*glowicar); - ++glowicaw; - ++glowicar; - } - /* Wydruk testowy. */ - cout << "test2 : " << (int) name << endl ; - - }; - - Person& operator=(const Person& os) - { - //free(this->name); - this->name=os.name; - - return *this; - }; - - ~Person() - { - //cout << "Desktruktor ~Person" << endl; - free(name); - }; -}; - -class Couple -{ - Person *husb, *wife; -public: - friend ostream& operator<<(ostream& str, const Couple& p) - { - str << "He: " << *p.husb << " , She: " << *p.wife << endl; - }; - Couple(const char* m, const char* z) - { - husb = new Person(m); - wife = new Person(z); - }; - Couple(const Couple& p) - { - husb = new Person( *p.husb ); - wife = new Person( *p.wife ); - }; - Couple& operator=(const Couple& p) - { - //free(this->husb->name); - //free(this->wife->name); - //free(this->husb); - //free(this->wife); - - this->husb = new Person(*p.husb); - this->wife = new Person(*p.wife); - - return *this; - }; - ~Couple() - { - //cout << "Desktruktor ~Couple" << endl; - free(husb->name); - free(wife->name); - - free(husb); - free(wife); - }; -}; - -int main(void) -{ - Person person1("Mariusz"); - Person person2(person1); - - cout << person1 << endl; - cout << person2 << endl; - - Person *person_c1 = new Person("John"); - Person person_c2("Bert"); - *person_c1 = person_c2; - Person person_c3(*person_c1); - delete person_c1; - cout << person_c3 << endl; - - Couple *c1 = new Couple("John","Sue"); - Couple c2("Bert","Elsa"); - *c1 = c2; - Couple c3(*c1); - delete c1; - cout << c3 << endl; //He: Bert, She: Elsa - - //system("Pause"); - return 0; -} diff --git a/Zadanie7/Zadanie7.cpp b/Zadanie7/Zadanie7.cpp deleted file mode 100644 index 553a113..0000000 --- a/Zadanie7/Zadanie7.cpp +++ /dev/null @@ -1,192 +0,0 @@ -#include -#include -#include - -using namespace std; - -class Person -{ - char* name; - - public: - friend class Couple; - /********************************************************/ - friend ostream& operator<<(ostream& str, const Person& os) - { - cout << "Person: " << os.name << "\n"; - } - - /*******************************************/ - Person() - { - name = NULL; - } - /*******************************************/ - Person(const char* n) - { - /* Jak dluga jest tablica? */ - int licznik, licznik1; - const char *glowicar; - char* glowicaw; - - glowicar = n; - licznik = 0; - while( *glowicar != 0) - { - ++glowicar; - ++licznik; - } - cout << "as = " <<(int) glowicar << endl; - /* Kopiowanie. */ - glowicar = n; - name = (char*)malloc( (licznik + 1)*sizeof(char) ); - glowicaw = name; - for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) - { - *glowicaw = (char)(*glowicar); - ++glowicaw; - ++glowicar; - } - - /* Wydruk testowy. */ - cout << "Person : " << name << "\n"; - } - - - /*******************************************/ - Person(const Person& os) - { - - /* Jak dluga jest tablica? */ - int licznik, licznik1; - char *glowicar; - char* glowicaw; - - glowicar = os.name; - licznik = 0; - while( *glowicar != 0) - { - ++glowicar; - ++licznik; - } - - /* Kopiowanie. */ - glowicar = os.name; - name = (char*)malloc( (licznik + 1)*sizeof(char) ); - glowicaw = name; - for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) - { - *glowicaw = (char)(*glowicar); - ++glowicaw; - ++glowicar; - } - - /* Wydruk testowy. */ - cout << "Person : " << name << "\n"; - } - /*************************************/ - Person& operator=(const Person& os) - { - - /* Jak dluga jest tablica? */ - int licznik, licznik1; - char *glowicar; - char* glowicaw; - - glowicar = os.name; - licznik = 0; - while( *glowicar != 0) - { - ++glowicar; - ++licznik; - } - - /* Kopiowanie. */ - glowicar = os.name; - free(this->name); - this->name = (char*)malloc( (licznik + 1)*sizeof(char) ); - glowicaw = this->name; - for(licznik1 = 0; licznik1 < licznik + 1; ++licznik1) - { - *glowicaw = (char)(*glowicar); - ++glowicaw; - ++glowicar; - } - - /* Wydruk testowy. */ - cout << "Person : " << this->name << "\n"; - - return *this; - } - /*************************************/ - /*************************************/ - ~Person() - { - free(name); - } -}; - -class Couple -{ - Person *husb, *wife; - - public: - friend ostream& operator<<(ostream& str, const Couple& p) - { - cout << "Husband: " << *(p.husb) << " & wife: " << *(p.wife) << "\n"; - } - /***********************************/ - Couple(const char* m, const char* z) - { - husb = new Person(m); - wife = new Person(z); - - } - /*********************/ - Couple(const Couple& p) - { - husb = new Person(*(p.husb)); - wife = new Person(*(p.wife)); - } - /********************************/ - Couple& operator=(const Couple& p) - { - free(this->husb->name); - free(this->wife->name); - free(this->husb); - free(this->wife); - - this->husb = new Person(*(p.husb)); - this->wife = new Person(*(p.wife)); - - return *this; - - } - /*******/ - ~Couple() - { - free(husb->name); - free(wife->name); - free(husb); - free(wife); - } -}; - -int main(void) -{ - Couple *c1 = new Couple("John","Sue"); - Couple c2("Bert","Elsa"); - *c1 = c2; - Couple c3(*c1); - delete c1; - cout << c3 << endl; - - - //Person p1("DUPA1"); - //Person p2("DUPA2"); - //p1 = p2; - //cout << p1; - - system("pause"); - -} diff --git a/Zadanie7/makefile b/Zadanie7/makefile deleted file mode 100644 index 746eebe..0000000 --- a/Zadanie7/makefile +++ /dev/null @@ -1,2 +0,0 @@ -clean: - rm -f *.out diff --git a/a.out b/a.out deleted file mode 100755 index 9b6f55b..0000000 Binary files a/a.out and /dev/null differ diff --git a/decyzja kredytowa.cpp b/decyzja kredytowa.cpp deleted file mode 100644 index 218ab9e..0000000 --- a/decyzja kredytowa.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include -#include -using namespace std; -class decyzja { - -private: -string nazwisko; -int wynagr; -bool czyauto; -bool czychata; -bool czym; -bool czyprzelewa; -bool czykarta; - -public: -decyzja() {nazwisko=""; wynagr=0; czyauto=false; czychata=false; czym=false; czyprzelewa=false; czykarta=false;}//k bez par - -decyzja(string pnazwisko, int pwynagr, bool pczyauto, bool pczychata, bool pczym, bool pczyprzelewa, bool pczykarta) -{nazwisko=pnazwisko; wynagr=pwynagr; czyauto=pczyauto; czychata=pczychata; czym=pczym; czyprzelewa=pczyprzelewa; czykarta=pczykarta;}//k par - -void podejmij () { -int param=0; - if (wynagr<1000) param=-10; - if (wynagr>2000) param++; - if (wynagr>4000) param++; - if (czyauto=true) param++; - if (czychata=true) param++; - if (czym=true) param++; - if (czyprzelewa=true) param++; - if (czykarta=true) param++; - - if (param>4) - cout<<"Pan "< -#include -#include -using namespace std; - -class lokata { -private: -string imie; -string nazwisko; -int kwotalok; -int ildni; - -public: -lokata() {imie=""; nazwisko=""; kwotalok=0; ildni=0;}//k bez par -//lokata(string pimie, string pnazwisko, int pkwotalok, int pildni) {imie=pimie; nazwisko=pnazwisko; kwotalok=pkwotalok; ildni=pildni;} -lokata(string pimie, string pnazwisko, int pkwotalok, int pildni) {imie=pimie; nazwisko=pnazwisko; kwotalok=pkwotalok; ildni=pildni;}//k par - -void obliczodsetki () { - float procent=0.06, odsetki=0; - if (kwotalok>20000) procent=0.07; - odsetki=kwotalok*ildni*procent; - cout<<"Imie: "< -using namespace std; - - int main () - { - int liczba = 80; - int *wskaznik = &liczba; - - cout << liczba << " jjjddddddddj" << &liczba << endl; - cout << wskaznik << " " << *wskaznik << endl; - - *wskaznik = 42; - cout << liczba << " " << *wskaznik << endl; - - liczba =32; - cout << liczba << " " << *wskaznik << endl; - - liczba =0x30; - cout << liczba << " " << *wskaznik << endl; - - //system("Pause"); - return 0; - } diff --git a/zad7.cpp b/zad7.cpp deleted file mode 100644 index 5f8a52b..0000000 --- a/zad7.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include -#include //free && mallock w cstdlib -//las -using namespace std; - - -class Person { - char* name; //private - - public: - - friend class Couple; - - friend ostream& operator<<(ostream& str, const Person& os) - { - str<name = os.name; - return *this; //this to wskaznik na aktualny obiekt - }; - - ~Person() - { - free(name); //funkcja zwalniajaca pamiec - cout<<"destr"<husb = new Person(*p.husb); - this->wife = new Person(*p.wife); - return *this; - }; - - - ~Couple() - { - free(husb->name); - free(wife->name); - free(husb); - free(wife); - }; - -}; - -int main(void) { - - -Couple *c1 = new Couple("John","Sue"); -Couple c2("Bert","Elsa"); -*c1 = c2; -Couple c3(*c1); -delete c1; -cout << c3 << endl; - - -/* -Person person1("naaapis"); -Person person2(person1); -Person person3("Waldek"); - -cout<