11 条题解

  • 4
    @ 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
      @ 2025-11-23 20:26:22
      #include<bits/stdc++.h>
      using namespace std;
      
      int main()
      {
      	double x1,y1,x2,y2,x3,y3;
      	cin>>x1>>y1>>x2>>y2>>x3>>y3;
      	double s=0.5*abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1));
      	cout<<fixed<<setprecision(2)<<s;
      	return 0;
      }
      
      • 0
        @ 2025-7-12 15:25:45

        #include <bits/stdc++.h> using namespace std; int main(){ double x1,y1,x2,y2,x3,y3; cin>>x1>>y1>>x2>>y2>>x3>>y3; double m,n,e,p,s; 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; }

        • 0
          @ 2024-10-4 13:01:25

          #include <stdio.h> #include #include #include <math.h> using namespace std; int main() { float x1,y1,x2,y2,x3,y3,xy1,xy2,xy3,a,b,c,d,e,f,g,p; cin>>x1>>y1>>x2>>y2>>x3>>y3; if(x1-x20){ a = y1-y2; b = y2-y1; xy1 = max(a,b); }else{ if(y1-y20){ a = x1-x2; b = x2-x1; xy1 = max(a,b); }else{ a = y1-y2; b = y2-y1; c = max(a,b); d = x1-x2; e = x2-x1; f = max(d,e); xy1 = sqrt(cc+ff); } } if(x2-x30){ a = y2-y3; b = y3-y2; xy2 = max(a,b); }else{ if(y2-y30){ a = x2-x3; b = x3-x2; xy2 = max(a,b); }else{ a = y2-y3; b = y3-y2; c = max(a,b); d = x2-x3; e = x3-x2; f = max(d,e); xy2 = sqrt(cc+ff); } } if(x3-x10){ a = y3-y1; b = y1-y3; xy3 = max(a,b); }else{ if(y3-y10){ a = x3-x1; b = x1-x3; xy3 = max(a,b); }else{ a = y3-y1; b = y1-y3; c = max(a,b); d = x3-x1; e = x1-x3; f = max(d,e); xy3 = sqrt(cc+ff); } } p = (xy1+xy2+xy3)/2; g = sqrt(p*(p-xy1)(p-xy2)(p-xy3)); cout<<fixed<<setprecision(2)<<g; return 0; }

          • 0
            @ 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;
            }
            
            
            • -2
              @ 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;
              }
              
              • -5
                @ 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);
                }
                
              • -5
                @ 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);
                }
                
                • -6
                  @ 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);
                  }
                  
                • -7
                  @ 2022-2-8 19:18:03

                  #include <stdio.h> #include <math.h> #include 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); }

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

                    #include <stdio.h> #include #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
                    标签
                    递交数
                    548
                    已通过
                    295
                    上传者