Tính diện tích tam giác

View as PDF

Submit solution

Points: 0.10
Time limit: 1.5s
Memory limit: 64M

Authors:
Problem type
Mô tả vấn đề

Viết chương trình nhập vào tọa độ của 3 điểm trong mặt phẳng Oxy. Nếu 3 điểm lập thành tam giác, hãy tính diện tích của tam giác đó.Nếu không thì in "NO"

Input

Nhập tọa độ 3 điểm

Output

In ra diện tích của tam giác đó.Nếu không thì in "NO"

Sample Input 1
1 1
2 2
3 3
Sample Output 1
NO
Sample Input 2
0 0
1 2
1 -2
Sample Output 2
2

Comments

Please read the guidelines before commenting.



  • -1
    cukhoaimat  commented on Sept. 9, 2025, 3:43 p.m.

    include <bits/stdc++.h>

    using namespace std; double a,b,c,d,x,y,z,t,e,f; int main() { cin>>a>>b>>c>>d>>e>>f; x=sqrt(pow(c-a,2)+pow(d-b,2)); y=sqrt(pow(e-a,2)+pow(f-b,2)); z=sqrt(pow(e-c,2)+pow(f-d,2)); t=(x+y+z)/2; if(x < y + z && y < x + z && z < x + y) { cout<<sqrt(t(t-x)(t-y)*(t-z)); } else { cout<<"NO"; } } đây mới là bài đúng


  • -1
    cukhoaimat  commented on Sept. 9, 2025, 3:40 p.m.

    include <bits/stdc++.h>

    using namespace std; long long a,b,c,d,x,y,z,t,e,f; int main() { cin>>a>>b>>c>>d>>e>>f; x=sqrt(pow(c-a,2)+pow(d-b,2)); y=sqrt(pow(e-a,2)+pow(f-b,2)); z=sqrt(pow(e-c,2)+pow(f-d,2)); t=(x+y+z)/2; if(x < y + z && y < x + z && z < x + y) { cout<<sqrt(t(t-x)(t-y)*(t-z)); } else { cout<<"NO"; } }