Μόλις τελείωσα:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define RAD2DEG 57.2957795138210
#define EPS 1e-8
int main() {
double a, b, c, gA, gB, gC, p, e, t;
register int k;
for (k=1;scanf("%lf %lf %lf",&a,&b,&c)==3;k++) {
printf("%08d: a=%8.3lf b=%8.3lf c=%8.3lf", k, a, b, c);
if (a+b>=c && a+c>=b && b+c>=a) {
p=a+b+c;
t=p/2.0;
e=sqrt(t*(t-a)*(t-b)*(t-c));
gA=acos(0.5*((b*b+c*c)-a*a)/(b*c))*RAD2DEG;
gB=acos(0.5*((a*a+c*c)-b*b)/(a*c))*RAD2DEG;
gC=acos(0.5*((b*b+a*a)-c*c)/(b*a))*RAD2DEG;
printf("\n gA=%8.3lf gB=%8.3lf gC=%8.3lf", gA, gB, gC);
printf("\n Perimeter=%8.3lf Area=%8.3lf", p, e);
if (fabs(a-b)<EPS && fabs(a-c)<EPS)
printf(" is Equilateral");
else if (fabs(a-b)<EPS || fabs(a-c)<EPS || fabs(b-c)<EPS)
printf(" is Isosceles");
else
printf(" is Scalene");
if (fabs(gA-90)<EPS || fabs(gB-90)<EPS || fabs(gC-90)<EPS)
printf(" and is right-angled.\n");
else if (gA>90 || gB>90 || gC>90)
printf(" and is Obtuse.\n");
else
printf(" and is Acute.\n");
} else {
printf(" is NOT a triangle.\n");
}
}
return 0;
}
με αυτό το αρχείο:
3 4 5
9 9 9
3 4 7
3.0 4.0000001 4.9999999
1 2 1
3 2 2
1 3 1
δίνει:
00000001: a= 3.000 b= 4.000 c= 5.000
gA= 36.870 gB= 53.130 gC= 90.000
Perimeter= 12.000 Area= 6.000 is Scalene and is right-angled.
00000002: a= 9.000 b= 9.000 c= 9.000
gA= 60.000 gB= 60.000 gC= 60.000
Perimeter= 27.000 Area= 35.074 is Equilateral and is Acute.
00000003: a= 3.000 b= 4.000 c= 7.000
gA= 0.000 gB= 0.000 gC= 180.000
Perimeter= 14.000 Area= 0.000 is Scalene and is Obtuse.
00000004: a= 3.000 b= 4.000 c= 5.000
gA= 36.870 gB= 53.130 gC= 90.000
Perimeter= 12.000 Area= 6.000 is Scalene and is Acute.
00000005: a= 1.000 b= 2.000 c= 1.000
gA= 0.000 gB= 180.000 gC= 0.000
Perimeter= 4.000 Area= 0.000 is Isosceles and is Obtuse.
00000006: a= 3.000 b= 2.000 c= 2.000
gA= 97.181 gB= 41.410 gC= 41.410
Perimeter= 7.000 Area= 1.984 is Isosceles and is Obtuse.
00000007: a= 1.000 b= 3.000 c= 1.000 is NOT a triangle.
Καλή Χρονιά σε όλους...