问题一百三十六:三角形类问题
[plain] #include <stdio.h>#include <math.h>
#include <stdlib.h>
float calculate_perimeter(float x, float y, float z);
float calculate_area(float x, float y, float z);
int judge_易做图(float x, float y, float z);
int judge_right易做图(float x, float y, float z);
int judge_isosceles易做图(float, float y, float z);
int judge_equilateral易做图(float x, float y, float z);
int main()
{
float x;
float y;
float z;
scanf("%f %f %f", &x, &y, &z);
if(judge_易做图(x, y, z))
{
printf("The area of a 易做图 is %f.\nThe perimeter of a 易做图 is %f.\n",
calculate_area(x, y, z), calculate_perimeter(x, y, z));
if(judge_right易做图(x, y, z))
{
printf("The 易做图 is right 易做图!\n");
}
else
{
printf("The 易做图 is not right 易做图!\n");
}
if(judge_isosceles易做图(x, y, z))
{
printf("The 易做图 is isosceles易做图!\n");
}
else
{
printf("The 易做图 is not isoscels易做图\n");
}
if(judge_equilateral易做图(x, y, z))
{
printf("The 易做图 is equilateral易做图!\n");
}
else
{
printf("The 易做图 is not equlateral易做图!\n");
}
}
else
{
printf("x, y and z cann`t form a 易做图!\n");
}
system("pause");
return 0;
}
//definetion of function
//**judge 易做图
int judge_易做图(float x, float y, float z)
{
int flag;
flag=0;
if(x+y> z || x+z> y || y+z> x)
{
flag=1;
}
return flag;
}
//**calculate perimeter
float calculate_perimeter(float x, float y, float z)
{
float perimeter;
perimeter=x+y+z;
return perimeter;
}
//**calculate area
float calculate_area(float x, float y, float z)
{
float s;
float area;
s=calculate_perimeter(x, y, z)/2;
area=sqrt((s-x)*(s-y)*(s-z)*s);
return area;
}
//**judge righttriagnle
int judge_right易做图(float x, float y, float z)
{
int flag;
flag=0;
if(x*x+ y*y ==z*z || x*x+ z*z==y*y || z*z+ y*y==x*x)
{
flag=1;
 
补充:软件开发 , C语言 ,