我会在这里使用什么数学函数? [英] What Math Function Would I Use Here?

查看:76
本文介绍了我会在这里使用什么数学函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名初学程序员,并且被要求创建一个程序,要求用户给出三角形斜边的长度,程序假设三角形是一个30,60,90度的三角形(右边)三角)并给另外两边。



我得到了那边a = hyp * Cos(30)和b = hyp * Sin(30)。我只是不确定如何在C中使用数学库函数。这是我的代码到目前为止:





 {
float 斜边;

printf( 输入斜边的长度:);
scanf( %f,& hypotenuse);
printf( 您输入的是斜边=%9.2f \ n,斜边);
}

解决方案

请查看我对该问题的评论,并尝试至少更加独立。到目前为止,你并没有处于最小的工作状态。 :-)



使用C,你可以使用math.h:

http://www.techonthenet.com/c_language/standard_library_functions/math_h/cos.php [ ^ ],

http://www.techonthenet.com/c_language/standard_library_functions/math_h/sin.php [ ^ ]。



使用C ++和tmath.h,您可以使用函数的类型通用宏版本:

http://www.cplusplus.com/reference/cmath/cos [ ^ ],

http://www.cplusplus。 com / reference / cmath / sin / [ ^ ]。



-SA


你可能想要开始这里 [ ^ ]



通过Googling C#trig函数得到它。


实际上你甚至不需要三角函数。你的直角三角形恰好是等长三角形的一半。所以 a 非常简单,只需要 sqrt 来查找 b

I am a beginning programmer and have been asked to create a program that asks the user to give length for a hypotenuse of a Triangle and the program is supposes to assume that the Triangle is a 30,60,90 degree triangle (right triangle) and give the other two sides.

I was given that side a=hyp*Cos(30) and b=hyp*Sin(30). Im just not sure how to use the math library functions in C. Here is my code so far:


{
float hypotenuse;

printf("Enter the length of the hypotenuse:");
scanf("%f", &hypotenuse);
printf("You have entered that the hypotenuse=%9.2f\n",hypotenuse);
}

解决方案

Please see my comments to the question and try to become at least a bit more independent. So far, you are not in a minimal working shape. :-)

With C, you can use "math.h":
http://www.techonthenet.com/c_language/standard_library_functions/math_h/cos.php[^],
http://www.techonthenet.com/c_language/standard_library_functions/math_h/sin.php[^].

With C++ and "tmath.h", you could have type-generic macro version of the functions:
http://www.cplusplus.com/reference/cmath/cos[^],
http://www.cplusplus.com/reference/cmath/sin/[^].

—SA


You'd probably want to start here [^]

Got that by Googling C# trig functions.


Actually you didn't even need trigonometric functions. Your right triangle is exactly the half on an equilater one. So a is really simple to know while you just need sqrt to findo out b.


这篇关于我会在这里使用什么数学函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆