8. 正弦和余弦

题目:

输入正整数 n (n < 360),输出 n 度的正弦,余弦函数值。提示:使用数学函数。

思路:

使用函数库中的函数即可。

代码:

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
const double PI = acos(-1.0);

double n = 0;
cin >> n;

double n_sin = sin(n / 180 * PI);
double n_cos = cos(n / 180 * PI);

cout << setprecision(3) << fixed << n_sin << endl;
cout << setprecision(3) << fixed << n_cos << endl;

return 0;
}

猜你喜欢

转载自www.cnblogs.com/Hello-Nolan/p/12110194.html
今日推荐