2017-10-15 16 views
0

我写这篇文章的代码来获得0 90之间计算0至90之间的角度增加15

例如角度罪:

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; 
} 
+1

你还应该阅读https://linux.die.net/man/3/sin,参数是弧度,所以'sin(90)'不会是'1' – mch

回答

0

这是因为你的循环条件不正确。你需要从

for(i=0; i>90; i=i+15) 

纠正你的for循环到

for (i=0; i<=90; i=i+15) 

还能去除; for循环之后。

+1

你应该包含@mch的警告说角度不是以你的答案为准。 –

相关问题