8 条题解

  • 2
    @ 2023-1-23 15:35:33

    怎么算面积——海伦公式:

    S=sqrt(p(p-a)(p-b)(p-c));

    p=(a+b+c)/2;

    可是a,b,c都是边长,怎么算呢?

    当然就用勾股定理啊!

    代码:

    #include <iostream>
    #include <cmath>
    using namespace std;
    int main(){
    	double x1,x2,x3,y1,y2,y3;
    	cin>>x1>>y1>>x2>>y2>>x3>>y3;
    	double a,b,c;
    	a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    	b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    	c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    	double p=(a+b+c)/2;
    	double S=sqrt(p*(p-a)*(p-b)*(p-c));
    	printf("%.2f",S); 
    	return 0;
    }
    
    • 1
      @ 2023-6-13 17:39:28
      #include <iostream>
      #include <stdio.h>
      #include <iomanip>
      #include <math.h>
      using namespace std;
      const int N = 1e6 + 10;
      const int INF = 0x3f3f3f3f;
      int main()
      {
      	double a , b , c , d;
      	float x1 , y1 , x2 , y2 , x3 , y3 , s;
      	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
      	a = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
      	b = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
      	c = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
      	d = (a + b + c) / 2;
      	s = sqrt(d * (d - a) * (d - b) * (d - c));
      	cout << fixed << setprecision(2) << s;
      	return 0;
      }
      
      
      • 0
        @ 2022-10-30 16:41:02
        #include <bits/stdc++.h>
        
        using namespace std;
        
        int main(void)
        {
            double x1, y1;
            double x2, y2;
            double x3, y3;
        
        	double m, n, e, p, s;
        
        	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
        	m = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        	n = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
        	e = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
        	p = (m + n + e) / 2;
        	s = sqrt(p * (p - m) * (p - n) * (p - e));
        
        	cout << fixed << setprecision(2) << s;
        
        	return 0;
        }
        
        • -3
          @ 2022-1-2 13:59:36
          #include <stdio.h>
          #include <iostream>
          #include <math.h>
          using namespace std;
          int main()
          {
          	double x1,x2,x3,y1,y2,y3;
          	double a, b, c, p, s;
          	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
          	a = sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
          	b = sqrt( (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
          	c = sqrt( (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
          	p = (a + b + c) / 2;
          	s = sqrt(p * (p - a) * (p - b) * (p -c));
          	printf("%.2lf",s);
          }
          
        • -3
          @ 2022-1-2 13:58:21
          #include <stdio.h>
          #include <iostream>
          #include <math.h>
          #include <iomanip>
          using namespace std;
          int main()
          {
          	double x1,y1,x2,y2,x3,y3;
          	double a, b, c, p, s;
          	cin >>x1>>y1>>x2>>y2>>x3>>y3;
          	a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
          	b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
          	c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
          	p=(a+b+c)/2;
          	s=sqrt(p*(p-a)*(p-b)*(p-c));
          	printf ("%.2lf\n",s);
          }
          
          • -3
            @ 2022-1-2 13:57:08
            #include <stdio.h>
            #include <iostream>
            #include <math.h>
            #include <iomanip>
            using namespace std;
            int main()
            {
            	double x1,y1,x2,y2,x3,y3;
            	double a, b, c, p, s;
            	cin >>x1>>y1>>x2>>y2>>x3>>y3;
            	a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
            	b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
            	c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
            	p=(a+b+c)/2;
            	s=sqrt(p*(p-a)*(p-b)*(p-c));
            	printf ("%.2lf\n",s);
            }
            
          • -5
            @ 2022-2-8 19:18:03

            #include <stdio.h> #include <math.h> #include <iostream> using namespace std; int main() { double x1,x2,x3,y1,y2,y3; cin >>x1>> y1 >>x2>>y2>>x3>>y3; double a,b,c; a = sqrt( (x1 - x2)(x1 - x2) + (y1-y2)(y1-y2) ); b = sqrt( (x1 - x3)(x1 - x3) + (y1-y3)(y1-y3) ); c = sqrt( (x3 - x2)(x3 - x2) + (y3-y2)(y3-y2) ); double p = (a + b + c)/2; double s = sqrt( p * (p-a) * (p-b) * (p-c)); printf("%.2lf\n",s); }

            • -5
              @ 2022-2-8 11:43:23

              #include <stdio.h> #include <iostream> #include <math.h> using namespace std; int main() { double x1,x2,x3,y1,y2,y3; double a, b, c, p, s; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; a = sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); b = sqrt( (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)); c = sqrt( (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2)); p = (a + b + c) / 2; s = sqrt(p * (p - a) * (p - b) * (p -c)); printf("%.2lf",s); }

              • 1

              信息

              ID
              825
              时间
              1000ms
              内存
              128MiB
              难度
              3
              标签
              递交数
              365
              已通过
              192
              上传者