Quick actions

cmd+k|ctrl+k

Navigation

Languages

三角形の面積(ヘロンの公式)

Snippet info

Language

C

Visibility

public

Author

potetotime

Created

2021-12-20T08:18:11.723629Z

Updated

2021-12-20T08:18:11.723629Z

#include <stdio.h>
#include <math.h>
int main(){
    double a,b,c,S,s;
    printf("三角形の3辺を記入(空白か改行で区切る)\n有効数字は小数点以下4桁まで\n無理数(平方根等)は記号は付けずに途中まで記入\n");
    scanf("%lf",&a);
    scanf("%lf",&b);
    scanf("%lf",&c);
    s=(a+b+c)/2;
    S=sqrt(s*(s-a)*(s-b)*(s-c));
    printf("a:%g,b:%g,c:%gの三角形ABCの面積は%.4g",a,b,c,S);
}
INFO