|
|
检测点10-4
编写程序,输入直角三角形两个直角边的长度,然后计算斜边的长度。
参考答案:
# include <stdio.h>
# include <math.h>
int main (void)
{
struct {float a; float b; float c;} tri;
printf ("请输入两个直角边的长度:");
scanf ("%f%f", & tri.a, & tri.b);
printf ("斜边长度:%f", tri.c = hypotf (tri.a, tri.b));
}
赠送答案:
# include <stdio.h>
# include <math.h>
int main (void)
{
float a, b, c;
printf ("请输入两个直角边的长度:");
scanf ("%f%f", & a, & b);
printf ("斜边长度:%f", c = hypotf (a, b));
}
|
|