我编写这段代码是为了获取 0 到 90 之间的角度的 sin
示例:
1: sin(0) =
2: sin(15)=
....
7: sin(90)=...
所以我写了这段代码,但他只向我显示一个结果 我的问题出在哪里?
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include <time.h>
int main()
{
int i;
float x;
for (i=0;i>90;i=i+15);
{
x = sin(i);
printf("sin(%d)= %f\n", i, x);
}
getch();
return 0;
}
最佳答案
这是因为您的循环条件错误。您需要更正您的 for 循环
for(i=0; i>90; i=i+15)
至
for (i=0; i<=90; i=i+15)
同时删除 for 循环后面的 ;
。
关于计算 0 到 90 之间的角度加 15,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46759447/