Last active
May 19, 2016 02:33
-
-
Save shimastripe/d6e5e0ca961a95920afc6b739d411bb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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