diff --git a/Laboratorium/20221116155920/structs.cpp b/Laboratorium/20221116155920/structs.cpp new file mode 100644 index 0000000..3807bd7 --- /dev/null +++ b/Laboratorium/20221116155920/structs.cpp @@ -0,0 +1,51 @@ +#include +#include + + +struct pointInSpace { + double xCoord; + double yCoord; +}; + +struct rectangle { + pointInSpace SW; + pointInSpace NE; +}; +struct circle { + pointInSpace centre; + double radius; + }; +double distance(pointInSpace a, pointInSpace b){ + return std::sqrt(std::pow(a.xCoord - b.xCoord, 2) + std::pow(a.yCoord - b.yCoord, 2)); +} +double rectArea(rectangle caseInPoint){ + return (caseInPoint.NE.xCoord-caseInPoint.SW.xCoord) * (caseInPoint.NE.yCoord-caseInPoint.SW.yCoord); +} + +int biggerRect(rectangle a, rectangle b){ + return (rectArea(a) > rectArea(b)) ? rectArea(a) : rectArea(b); +} + + + +int main(int argc, char* argv[]){ + pointInSpace dot = {3.141592, 42.0}; + std::cout << dot.xCoord << std::endl << dot.yCoord << std::endl; + + rectangle square = {0.0,0.0,20.0,20.0}; + std::cout << square.SW.xCoord << std::endl << square.SW.yCoord << std::endl << square.NE.xCoord << std::endl << square.NE.yCoord << std::endl; + + circle wheel = {1.0,1.0,1.0}; + std::cout << wheel.centre.xCoord << std::endl << wheel.centre.yCoord << std::endl << wheel.radius << std::endl; + + std::cout << distance({1.0,1.0},{3.0,1.0}) << std::endl; + + std::cout << rectArea(square) << std::endl; + + rectangle rect1 = {13.0,10.0,15.0,15.0}; + std::cout << biggerRect(square,rect1) << std::endl; + + + return 0; + +}