Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.cpp
- * Author: roman
- *
- * Created on October 6, 2019, 1:21 PM
- */
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <stdlib.h>
- #include <time.h>
- #include <cmath>
- #include <complex>
- using namespace std;
- struct Punkt{
- double x;
- double y;
- Punkt() {
- }
- Punkt(double x, double y) :
- x(x), y(y) {
- }
- };
- class Trojkat {
- Punkt a,b,c;
- int ab, bc, ca;
- void computeLenght(){
- ab = sqrt(pow(b.x - a.x, 2) + pow(b.y - a.y, 2));
- bc = sqrt(pow(c.x - b.x, 2) + pow(c.y - b.y, 2));
- ca = sqrt(pow(a.x - c.x, 2) + pow(a.y - c.y, 2));
- }
- public:
- Trojkat() : a(Punkt()), b(Punkt()), c(Punkt()) {
- }
- Trojkat(Punkt a, Punkt b, Punkt c) :
- a(a), b(b), c(c) {
- computeLenght();
- }
- Trojkat(double ax, double ay, double bx, double by, double cx, double cy)
- : a(Punkt(ax,ay)), b(Punkt(bx,by)), c(Punkt(cx, cy)) {
- computeLenght();
- }
- bool isTrojkat(){
- return ab+bc>ca || bc+ca>ab || ca+bc>ab;
- }
- bool isRownoboczny(){
- if(!isTrojkat()){
- return false;
- }
- return ab == bc == ca;
- }
- bool isRownoramienny(){
- if(!isTrojkat()){
- return false;
- }
- return (ab == bc) || (bc == ca) || (ca== ab);
- }
- bool isProstokatny(){
- if(!isTrojkat()){
- return false;
- }
- return pow(ab,2) + pow(bc,2) == pow(ca,2) ||
- pow(bc,2) + pow(ca,2) == pow(ab,2) ||
- pow(ca,2) + pow(ab,2) == pow(bc,2);
- }
- };
- int main(int argc, char** argv) {
- Trojkat a(6.0,1.0,1.0,1.0,6.0,1.0);
- cout<< a.isTrojkat()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement