Z_Beginner(初学者)
不对吧:
是不是这样 Math.sin(Math.PI*30/180)
不对吧:
是不是这样 Math.sin(Math.PI*30/180)
解决方案 »
- 求助,java用httpclient包,模拟发送json和接受json。
- JDBC基础,MyEclipse里面怎么查看数据库里面的内容啊?
- 求一个算法
- 高分求解..
- 关于通信接口的问题
- 求救: java 使用关键字类从Hashtable中取值(课本中的错误?)
- ArrayList和Vector,用哪个好,还是用别的
- jbuild能编译c#的程序吗?
- [help]请问能不能做出一个椭圆型的面板?
- 使用sybase出现SET CHAINED command not allowed within multi-statement transaction. 为什么会出现这种情况呢
- 请问SWING的UI类如何使用,最好有例子。 50分
- 如何让JFileChooser中可以显示文件但是不允许用户选择?
Math.sin(2*Math.PI*30/360)
Returns the trigonometric sine of an angle. Special cases:
If the argument is NaN or an infinity, then the result is NaN.
If the argument is zero, then the result is a zero with the same sign as the argument.
A result must be within 1 ulp of the correctly rounded result. Results must be semi-monotonic.
Parameters:
a - an angle, in radians.
Returns:
the sine of the argument.
// acos, asin, atan, atan2, cos, cosh, sin, sinh, tan, tanh
//////////////////////////////////////////////////////////////////////#include <iostream> // for i/o functions
#include <valarray> // for valarray
#include <cmath> // for trigonometry functionsusing namespace std ;#define ARRAY_SIZE 3 // array sizevoid main()
{
// Initialize val_array to values -1, 0 and 1.
valarray<double> val_array(ARRAY_SIZE);
for (int i = 0; i < ARRAY_SIZE; i++)
val_array[i] = i - 1; // Display the size of val_array.
cout << "Size of val_array = " << val_array.size() << endl; // Display the values of val_array before calling any trigonometry
// functions.
cout << "The values in val_array:" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << val_array[i] << " ";
cout << endl << endl; // Initialize rev_valarray that is the reverse of val_array.
valarray<double> rev_valarray(ARRAY_SIZE);
for (i = 0; i < ARRAY_SIZE; i++)
rev_valarray[i] = val_array[ARRAY_SIZE - i - 1]; // Display the size of rev_valarray.
cout << "Size of rev_valarray = " << rev_valarray.size() << endl; // Display the values of rev_valarray.
cout << "The values in rev_valarray:" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rev_valarray[i] << " ";
cout << endl << endl; // rvalue_array to hold the return value from calling the trigonometry
// functions.
valarray<double> rvalue_array; // ----------------------------------------------------------------
// acos() - display the result of rvalue_array
// ----------------------------------------------------------------
rvalue_array = acos(val_array);
cout << "The result after calling acos():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// asin() - display the result of rvalue_array
// ----------------------------------------------------------------
rvalue_array = asin(val_array);
cout << "The result after calling asin():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// atan() - display the result of rvalue_array
// ----------------------------------------------------------------
rvalue_array = atan(val_array);
cout << "The result after calling atan():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// atan2() - display the result of rvalue_array
// ---------------------------------------------------------------- // This template function returns an object of class valarray<T>,
// each of whose elements at I is the arctangent of x[I] / y[I].
rvalue_array = atan2(val_array, rev_valarray);
cout << "The result after calling atan2(val_array, rev_valarray):"
<< endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // This template function stores in element I the arctangent of
// x[I] / y.
rvalue_array = atan2(val_array, 3.1416);
cout << "The result after calling atan2(val_array, 3.1416):" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // This template function stores in element I the arctangent of
// x / y[I].
rvalue_array = atan2(3.1416, val_array);
cout << "The result after calling atan2(3.1416, val_array):" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// cos() - display the result of rvalue_array
// ----------------------------------------------------------------
rvalue_array = cos(val_array);
cout << "The result after calling cos():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// cosh() - display the result of rvalue_array
// ----------------------------------------------------------------
rvalue_array = cosh(val_array);
cout << "The result after calling cosh():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// sin() - display the result of val_array
// ----------------------------------------------------------------
rvalue_array = sin(val_array);
cout << "The result after calling sin():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// sinh() - display the result of val_array
// ----------------------------------------------------------------
rvalue_array = sinh(val_array);
cout << "The result after calling sinh():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// tan() - display the result of val_array
// ----------------------------------------------------------------
rvalue_array = tan(val_array);
cout << "The result after calling tan():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl; // ----------------------------------------------------------------
// tanh() - display the result of val_array
// ----------------------------------------------------------------
rvalue_array = tanh(val_array);
cout << "The result after calling tanh():" << endl;
for (i = 0; i < ARRAY_SIZE; i++)
cout << rvalue_array[i] << " ";
cout << endl << endl;
}