D
D
didrux2020-10-11 23:50:27
C++ / C#
didrux, 2020-10-11 23:50:27

A problem in C about coordinates and a point and an area?

I will immediately forgive your forgiveness if I violate any rules of the Khabrov community. Please delete this post if so.

There is a problem:

On a plane, a region R bounded by lines y=x^2, y=2-x^2 and points A(x1,y1), B(x2,y2), C(x3,y3) are given. Make a program that calculates the perimeter and area of ​​triangle ABC, if points A, B, C belong to the area R and do not lie on the same line

Use only standard libraries, only C without C ++

If there are enthusiasts ready to solve the problem, write in the answers I will be very grateful
Or who is more practical - write to telegram didrux for a working code, I will send a couple of rubles much more convenient. Thank you !

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
didrux, 2020-10-12
@didrux

/*****COPYRIGHT BY MICHAEL DIDRUX OVDIIENKO CODE O.V MATVIY, 101-B, ChNU, 2020
*****/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    
    printf("Type each point of A,B,C\n");
    double per,ax,ay,bx,by,cx,cy,ab,ac,bc;
    printf("Point A(x1,y1) --> ");
    scanf("%lf%lf",&ax,&ay);
    printf("Point B(x2,y2) --> ");
    scanf("%lf%lf",&bx,&by);
    printf("Point C(x3,y3) --> ");
    scanf("%lf%lf",&cx,&cy);
    ab = sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
    ac = sqrt((ax-cx)*(ax-cx)+(ay-cy)*(ay-cy));
    bc = sqrt((cx-bx)*(cx-bx)+(cy-by)*(cy-by));
    per  = (ab+bc+ac)/2;
    if (!((ay >= 2*ax*ax && ay <= 2-ax*ax) && (by >= 2*bx*bx && by <= 2-bx*bx) &&  (cy >= 2*cx*cx && cy <= 2-cx*cx))){
        printf("Point's doesn't on the area\n");
    }
    else if (ab + bc == ac || ac+ bc == ab || ab+ac == bc){
        printf("Points on one line\n");        
    }
    else
        printf("S = %.2f\n", sqrt(per*(per-ab)*(per-bc)*(per-ac)));
    return 0;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question