求正弦函数
#include<stdio.h>
#include<math.h>
main()
{
double y,n;
int x,m;
for( x=0;x<=180;x++)
printf("%f\n",sin(float(3.14/(180/x))));
}
输出有错,何为
[解决办法]
x=0的时候出现除0中断了吧!
[解决办法]
将
sin(float(3.14/(180/x)))
该为:
sin(float(3.14 * x /180.0))
或者
sin(float(3.14/(180/(float)x)))
否则转型时x就变成0了。