Copy Code code as follows:
Area Formula S = (A+B+C)/2 areas = sqrt (S * (s-a) * (s-b) * (s-c));
Small job to find the area of the triangle
int check (double a);
int Check2 (double A, double b, double c);
#include <stdio.h>
#include <math.h>
int main (void)
{
Double area = 0;
Double S;
Double a,b,c;
printf ("Enter the length of the three sides of the triangle (a b C):");
scanf ("%lf%lf%lf", &a, &b, &c);
if (check (a) = = 1 && check (b) = = 1 && check (c) ==1)
{
if (Check2 (a,b,c) = = 0)
{
printf ("You are not entering a triangle. Please re-enter \n\r");
return 0;
}
else if (Check2 (a,b,c) = = 1)
{
s = (a+b+c)/2;
Area = sqrt (S * (s-a) * (s-b) * (s-c));
printf ("The size of the triangle is:%g\n\r", area);
}
}
Else
printf ("Input is incorrect, please re-enter. \n\r");
return 0;
}
Determine if the data entered is valid
int check (double a)
{
if (a > 0)
return 1;
Else
return 0;
}
Determine if the triangle is valid
int Check2 (double A, double b, double c)
{
if (((a+b) <=c) | ((a+c) <=b) | ((c+b) <=a))
return 0;
if (ABS (a-b) >=c | ABS (A-C) >=a | ABS (C-B) >=a)
return 0;
Else
return 1;
}
Think, area is not a garbage value ah. So don't write so many lines declaring variables eh ....
Modified a number of
Copy Code code as follows:
Area Formula S = (A+B+C)/2 areas = sqrt (S * (s-a) * (s-b) * (s-c));
Small job to find the area of the triangle
int check (double a);
int Check2 (double A, double b, double c);
#include <stdio.h>
#include <math.h>
int main (void)
{
Double area,s,a,b,c;
printf ("Enter the length of the three sides of the triangle (a b C):");
scanf ("%lf%lf%lf", &a, &b, &c);
if (check (a) = = 1 && check (b) = = 1 && check (c) ==1)
{
if (Check2 (a,b,c) = = 0)
{
printf ("You are not entering a triangle. Please re-enter \n\r");
return 0;
}
else if (Check2 (a,b,c) = = 1)
{
s = (a+b+c)/2;
Area = sqrt (S * (s-a) * (s-b) * (s-c));
printf ("The size of the triangle is:%g\n\r", area);
}
}
Else
printf ("Input is incorrect, please re-enter. \n\r");
return 0;
}
Determine if the data entered is valid
int check (double a)
{
if (a > 0)
return 1;
Else
return 0;
}
Determine if the triangle is valid
int Check2 (double A, double b, double c)
{
if (((a+b) <=c) | ((a+c) <=b) | ((c+b) <=a))
return 0;
if (ABS (a-b) >=c | ABS (A-C) >=a | ABS (C-B) >=a)
return 0;
Else
return 1;
}