Pasta: fc342b6b79591479dd70dec74a6c74850efaed25 (2017-11-28)

Język: Text
Adres: p43.pl/p,fc342b6b79591479dd70dec74a6c74850efaed25
Ilość linii: 269
Rozmiar: 4.11 kB
Wyświetleń: 203
Ostatnio użyto: 2018-10-21 16:20:17
#include <iostream> using namespace std; class punkt { double X,Y,Z; public: punkt() : X(0), Y(0), Z(0) {} punkt(const double & x, const double & y, const double & z) : X(x), Y(y), Z(z) {} const double x() const { return X; } double & x() { return X; } const double y() const { return Y; } double & y() { return Y; } const double z() const { return Z; } double & z() { return Z; } }; class prostokat { punkt P; double A,B; public: prostokat(): P(), A(0), B(0) {} prostokat(const double &x, const double &y, const double &z, const double &a, const double &b): P(x,y,z), A(a), B(b){} prostokat(const punkt &p, const double &a, const double &b): P(p), A(a), B(b){} const double x() const { return P.x(); } double &x() { return P.x(); } const double y() const { return P.y(); } double &y() { return P.y(); } const double z() const { return P.z(); } double &z() { return P.z(); } const double a() const { return A; } double &a() { return A; } const double b() const { return B; } double &b() { return B; } const double pole() const { return A*B; } }; class graniastoslup { prostokat PR; double H; public: graniastoslup(): PR(), H(0) {} graniastoslup(const double &x, const double &y, const double &z, const double &a, const double &b, const double &h ): PR(x,y,z,a,b), H(h) {} graniastoslup(const punkt &p, const double &a, const double &b, const double &h): PR(p,a,b), H(h) {} graniastoslup(const prostokat &pr, const double &h): PR(pr), H(h) {} double &x() { return PR.x(); } const double x() const { return PR.x(); } double &y() { return PR.y(); } const double y() const { return PR.y(); } double &z() { return PR.z(); } const double z() const { return PR.z(); } double &a() { return PR.a(); } const double a() const { return PR.a(); } double &b() { return PR.b(); } const double b() const { return PR.b(); } double &h() { return H; } const double h() const { return H; } const double objetosc() const { return (PR.pole()*H); } }; int main() { punkt p1, p2(1,2,3); const punkt p3(1.1,2.2,3.3); cout << p3.x() << '\t' << p3.y() << '\t' << p3.z() << endl; cout << p2.x() << '\t' << p2.y() << '\t' << p2.z() << endl; p1.x()=1; p1.y()=10; p1.z()=100; cout << p1.x() << '\t' << p1.y() << '\t' << p1.z() << endl; prostokat pr1, pr2(1,2,3,10.5, 20.5); const prostokat pr3(p2,5,5); cout << pr3.x() << '\t' << pr3.y() << '\t' << pr3.z() << '\n' << pr3.a() << '\t' << pr3.b() << '\n' << pr3.pole() << '\n' ; pr1.x()=2; pr1.y()=20; pr1.z()=200; pr1.a()= 10; pr1.b()=10; cout << pr1.x() << '\t' << pr1.y() << '\t' << pr1.z() << '\n' << pr1.a() << '\t' << pr1.b() << '\n' << pr1.pole() << '\n' ; graniastoslup g1, g2(1,2,3,10.5,20.5,30.5), g3(p2,100,200,300); const graniastoslup g4(pr3,5); cout << g4.x() << '\t' << g4.y() << '\t' << g4.z() << '\n' << g4.a() << '\t' << g4.b() << '\t' << g4.h() << '\n' << g4.objetosc() << '\n' ; g1.a()=10; g1.b()=10; g1.h()=10; cout << g1.x() << '\t' << g1.y() << '\t' << g1.z() << '\n' << g1.a() << '\t' << g1.b() << '\t' << g1.h() << '\n' << g1.objetosc() << '\n' ; }