1 条题解

  • 0
    @ 2025-4-7 21:28:46

    C :

    #include<stdio.h>
    #include<math.h>
    int main(){
    double a,b,c,s,L;
    scanf("%lf %lf %lf",&a,&b,&c);
    s=(a+b+c)/2;
    L=sqrt(s*(s-a)*(s-b)*(s-c));
    printf("%.2lf",L);
    return 0;
    }
    

    C++ :

    #include <stdio.h>
    #include <math.h>
    int main() {
    	float a, b, c, s, area;
    	scanf("%f %f %f", &a, &b, &c);
    	s = (a + b + c) * 0.5;
    	area = sqrt(s * (s - a) * (s - b) * (s - c));
    	printf("%.2f\n", area);
    	return 0;
    }
    
    

    Pascal :

    var
      a,b,c,d,s:double;
    begin
      readln(a,b,c);
      d:=(a+b+c)/2;
      s:=sqrt(d*(d-a)*(d-b)*(d-c));
      writeln(s:0:2);
    end.
    
    

    Java :

    import java.util.*;
    public class Main {
    	public static void main(String args[]) {
    		Scanner cin=new Scanner(System.in);
    		double a,b,c;
    		double p;
    		double hl;
    		a=cin.nextDouble();
    		b=cin.nextDouble();
    		c=cin.nextDouble();
    		p=(a+b+c)/2;
    		hl=Math.sqrt(p*(p-a)*(p-b)*(p-c));
    		System.out.printf("%.2f",hl);
    	}
    }
    

    Python :

    from math import sqrt
    a,b,c = [float(x) for x in raw_input().split()]
    p = (a+b+c)/2
    print "%.2f" %sqrt(p*(p-a)*(p-b)*(p-c))
    
    • 1

    信息

    ID
    1247
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者