Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define M_PI 3.14159265358979323846
- using namespace std;
- class punkt {
- public:
- int x, y;
- punkt() {
- x = 0;
- y = 0;
- }
- ~punkt() {
- cout << "destruktor sie wywolal" << endl;
- }
- void pobierzX() {
- int a;
- cout << "podaj X ";
- cin >> a;
- x = a;
- cout << endl;
- }
- void pobierzY() {
- int a;
- cout << "podaj Y ";
- cin >> a;
- y = a;
- cout << endl;
- }
- void wypisz() {
- cout << "wspolrzedne punktu to ( " << x << " , " << y << " )" << endl;
- }
- };
- class odcinek {
- public:
- punkt poczatek, koniec;
- void dlugosc() {
- cout << "dlugosc odcinka wynosi " << sqrt((poczatek.x - koniec.x)*(poczatek.x - koniec.x) + (poczatek.y - koniec.y)*(poczatek.y - koniec.y)) << endl;
- }
- void wczytajP() {
- int a, b;
- cout << "podaj X poczatku ";
- cin >> a;
- cout << endl << "podaj Y poczatku ";
- cin >> b;
- poczatek.x = a;
- poczatek.y = b;
- }
- void wczytajK() {
- int a, b;
- cout << "podaj X konca ";
- cin >> a;
- cout << endl << "podaj Y konca ";
- cin >> b;
- koniec.x = a;
- koniec.y = b;
- }
- odcinek() {
- poczatek.x = 0;
- poczatek.y = 0;
- koniec.x = 10;
- koniec.y = 10;
- }
- ~odcinek() {
- cout << "destruktor sie wywolal" << endl;
- }
- };
- class okrag {
- public:
- friend class odcinek;
- int licznik;
- punkt srodek;
- int promien;
- void wpiszS() {
- int a, b;
- cout << "podaj X srodka ";
- cin >> a;
- cout << endl << "podaj Y srodka ";
- cin >> b;
- srodek.x = a;
- srodek.y = b;
- }
- void wpiszP() {
- int a;
- cout << "podaj promien okregu ";
- cin >> a;
- promien = a;
- }
- void pole() {
- cout << "pole kola wynosi " << M_PI * promien*promien << endl;
- }
- void sprZaw(punkt p) {
- if (sqrt((p.x - srodek.x) * (p.x - srodek.x) + (p.y - srodek.y) * (p.y - srodek.y)) > promien) {
- cout << "podany punkt nie zawiera sie w okregu" << endl;
- }
- else
- cout << "podany punkt zawiera sie w okregu" << endl;
- }
- void wypisz() {
- cout << "wspolrzedne srodka okregu to " << srodek.x << " , " << srodek.y << " a promien jest rowny " << promien << endl;
- }
- okrag() {
- srodek.x = 0;
- srodek.y = 0;
- promien = 5;
- licznik++;
- }
- ~okrag() {
- cout << "destruktor sie wywolal" << endl;
- licznik--;
- }
- };
- void przeciecie(okrag a, okrag b) {
- if (sqrt((a.srodek.x - b.srodek.x) * (a.srodek.x - b.srodek.x) + (a.srodek.y - b.srodek.y) * (a.srodek.y - b.srodek.y)) == (a.promien + b.promien)) {
- cout << "podane okregi sa do siebie styczne " << endl;
- }
- else if (sqrt((a.srodek.x - b.srodek.x) * (a.srodek.x - b.srodek.x) + (a.srodek.y - b.srodek.y) * (a.srodek.y - b.srodek.y)) < (a.promien + b.promien))
- cout << "podane okregi sa rozlaczne zewnetrznie " << endl;
- else if (sqrt((a.srodek.x - b.srodek.x) * (a.srodek.x - b.srodek.x) + (a.srodek.y - b.srodek.y) * (a.srodek.y - b.srodek.y)) < (a.promien + b.promien))
- cout << "podane okregi sa rozlaczne zewnetrznie " << endl;
- }
- int main() {
- punkt p1;
- p1.wypisz();
- p1.pobierzX();
- p1.pobierzY();
- p1.wypisz();
- okrag o1;
- o1.wypisz();
- o1.sprZaw(p1);
- system("pause");
- return 0;
- }
- /*
- #include <iostream>
- #include <string>
- using namespace std;
- class Kalendarz{
- public:
- int day, month, year;
- void wpisz() {
- cout << "podaj dzien " << endl;
- cin >> day;
- cout << "podaj miesiac " << endl;
- cin >> month;
- cout << "podaj rok " << endl;
- cin >> year;
- }
- Kalendarz& operator++() {
- ++day;
- return *this;
- }
- Kalendarz& operator--() {
- --day;
- return *this;
- }
- Kalendarz() {
- day = 1;
- month = 1;
- year = 2000;
- }
- ~Kalendarz() {
- }
- };
- Kalendarz operator>(Kalendarz d1, Kalendarz d2) {
- if (d1.year > d2.year) {
- return d1;
- }
- else if (d1.year < d2.year) {
- return d2;
- }
- else if (d1.month > d2.month) {
- return d1;
- }
- else if (d1.month < d2.month) {
- return d2;
- }
- else if (d1.day > d2.day) {
- return d1;
- }
- else if (d1.day < d2.day) {
- return d2;
- }
- else {
- cout << " podano identyczne daty " << endl;
- }
- }
- ostream& operator<<(ostream& stm,Kalendarz qq) {
- stm << "dzien= " << qq.day << " miesiac= " << qq.month << " rok= " << qq.year << endl;
- return stm;
- }
- int main() {
- Kalendarz d1,d2,d3;
- cout << d1;
- d2.wpisz();
- cout << d2;
- ++d2;
- cout << d2;
- --d2;
- cout << d2;
- d3 = d1 > d2;
- cout << "pozniejsza jest data " << d3 ;
- system("pause");
- return 0;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement