1 solutions

  • 1
    @ 2024-7-20 20:09:52

    科普:本题如何计算

    1.勾股定理:先用勾股定理算出三条边的长度

    2.海伦公式:t=(a+b+c)/2 则三角形面积 =sqrt(t(t-a)(t-b)(t-c))

    3.y1是<math.h>里的自带函数,因此全局变量不能命名为y1

    #include<bits/stdc++.h>
    using namespace std;
    double x1,yi,x2,y2,x3,y3;
    int main(){
    	cin>>x1>>yi>>x2>>y2>>x3>>y3;
    	double a=sqrt((x1-x2)*(x1-x2)+(yi-y2)*(yi-y2));
    	double b=sqrt((x1-x3)*(x1-x3)+(yi-y3)*(yi-y3));
    	double c=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    	double p=(a+b+c)/2.0;
    	cout<<fixed<<setprecision(2)<<sqrt(p*(p-a)*(p-b)*(p-c));
    	return 0;
    }
    
    • 1

    Information

    ID
    6875
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    1
    Tags
    # Submissions
    5
    Accepted
    5
    Uploaded By