Let the three side length, judge whether the triangle can be formed, if possible, to find its area and perimeter
Program:
#include <stdio.h>
#include <math.h>
int Main ()
{
Double A, B, C, D, S, area;
printf ("Please enter three positive numbers:");
scanf ("%lf%lf%lf", &a,&b,&c);
if ( (A + B > C) && (A + C > B) && (b + C > a))
{
D = A + B + C;
s = 0.5*d;
Area = sqrt (s* (s-a) * (s-b) * (s-c));
printf ("d=%lf\tarea=%lf\t", D,area); //' \ t ' adjusts the output position to make the output data clear, neat and beautiful
}
Else
{
printf ("cannot form a triangle \ T");
}
return 0;
}
Results:
Please enter a three positive number: 4 5 6
d=15.000000 area=9.921567 Please press any key to continue ...
This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1718368
C language: Any three side length, judge whether to form a triangle, if possible, to find its area and perimeter