已知x=0, 10, 20, …, 180,求sinx,cosx和tanx的值。
#include<iostream> #include<cmath> #include<iomanip> using namespace std; int main() { const double pi = 3.14159265; int i; double x,y1,y2,y3; cout << setw(2) << "x" << setw(15) << "sin(x)" << setw(15) << "cos(x)" << setw(15) << "tg(x)" << endl; for( i=0; i<=18; i++ ) { x = i*10*pi/180; y1 = sin( x ); y2 = cos(x); y3 = y1/y2; cout << setw(2) << i*10 << setw(15) << y1 << setw(15) << y2 << setw(15) << y3 << endl; } }
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题