计算x=0,1,2,3,4,5,6,7,8,9情况下y=10*sin(x)的值,输出x和y的值.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 23:58:21
计算x=0,1,2,3,4,5,6,7,8,9情况下y=10*sin(x)的值,输出x和y的值.
计算x=0,1,2,3,4,5,6,7,8,9情况下y=10*sin(x)的值,输出x和y的值.
计算x=0,1,2,3,4,5,6,7,8,9情况下y=10*sin(x)的值,输出x和y的值.
编程吗?
设定变量i、x、y
进入循环
对于i=0到9,间隔为1
x=i
求y=10*sin(x)
输出x
输出y
下一个i
结束循环
#include
#include
int main()
{
\x09int i = 0;
\x09for(i=0; i<10; i++)
\x09{
\x09\x09printf("x=%d, y=%lf\n", i, 10.0*sin((double)(i)));
\x09}
}
0 8.4147 9.0930 1.4112 -7.5680 -9.5892 -2.7942 6.5699 9.8936
Column 10
4.1212
使用计算器,不然高人算死了也算不出来,sinx是周期为2派的函数,你给个有理数叫人怎么算?!
X=0, Y=0
X=1, Y=0.1745240643728351
X=2, Y=0.3489949670250097
X=3, Y=0.5233595624294383
X=4, Y=0.697564737441253
X=5, Y=0.8715574274765816
X=6, Y=1.045284632676...
全部展开
X=0, Y=0
X=1, Y=0.1745240643728351
X=2, Y=0.3489949670250097
X=3, Y=0.5233595624294383
X=4, Y=0.697564737441253
X=5, Y=0.8715574274765816
X=6, Y=1.0452846326765346
X=7, Y=1.2186934340514747
X=8, Y=1.3917310096006544
X=9, Y=1.5643446504023087 这样的精确度比较高,用是可以取近似值
收起