Skip to content

Instantly share code, notes, and snippets.

@shimastripe
Last active May 19, 2016 02:33
Show Gist options
  • Save shimastripe/d6e5e0ca961a95920afc6b739d411bb6 to your computer and use it in GitHub Desktop.
Save shimastripe/d6e5e0ca961a95920afc6b739d411bb6 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
double hero(double a,double b,double c){
double s,T;
if(a+b<c || b+c<a || c+a<b){
return -1;
}else{
s=(a+b+c)/2;
T=sqrt(s*(s-a)*(s-b)*(s-c));
return T;
}
}
int main(void){
double a,b,c, area;
printf("a = ");
scanf("%lf", &a);
printf("b = ");
scanf("%lf", &b);
printf("c = ");
scanf("%lf", &c);
if((area = hero(a,b,c)) != -1){
printf("T = %lf\n", area);
}else{
printf("三角形の入力が間違っています。");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment