题目
编写程序,提示用户输入三角形的三条边长,判断该三角形是否为直角三角形,若是则输出结果以及三角形面积.
提问时间:2021-03-16
答案
#include
void main(void)
{
int a,b,c;
double S;
int TRUE = 0;
printf("Enter three numbers for sides of a triangle:");
scanf("%d %d %d",&a,&b,&c);
if(a * a + b * b == c * c)
{
TRUE = 1;
S = a * b / 2;
}
if(b * b + c * c == a * a)
{
TRUE = 1;
S = b * c / 2;
}
if(c * c + a * a == b * b)
{
TRUE = 1;
S = c * a / 2;
}
if(TRUE == 1)
{
printf(" It is a right angle triangle. ");
printf("And the area of the triangle is %lf. ",S);
}
}
void main(void)
{
int a,b,c;
double S;
int TRUE = 0;
printf("Enter three numbers for sides of a triangle:");
scanf("%d %d %d",&a,&b,&c);
if(a * a + b * b == c * c)
{
TRUE = 1;
S = a * b / 2;
}
if(b * b + c * c == a * a)
{
TRUE = 1;
S = b * c / 2;
}
if(c * c + a * a == b * b)
{
TRUE = 1;
S = c * a / 2;
}
if(TRUE == 1)
{
printf(" It is a right angle triangle. ");
printf("And the area of the triangle is %lf. ",S);
}
}
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
- 1pass 和past across和cross
- 2the installation is complete
- 3设数列{an}满足:a1=2,a2=5/3,an+2=5/3an+1+1/3an(n=1,2,3,...)
- 4这里为什么用完成时,而不用一般过去时?has she made 换为did she made
- 5the book is very useful 感叹句
- 6I do not intend( )that,because we shall have an opportunity to do so on another occasion.
- 7:宽容的反面论据,
- 8已知一次函数y=kx+b的图像经过点A(-3,-2)及点B(1,6).求此一次函数的解析式?
- 9春天像(是)…… 造句
- 10椭圆x^2+y^2=1(a>b>0)的焦距为2
热门考点