2012-05-08 108 views
1

不知道什么问题在这里,但我不断得到0的结果。预期的结果是0.2222222。我想我必须将一个零分配给我的一个变量,但我无法弄清楚发生了什么。任何帮助,将不胜感激。由于C数学和零结果

#include <stdio.h> 
#include <math.h> 

int main() 
{ 
    double vs = 10; 
    double rs = 100; 
    double rl_start = 50; 
    double rl_stop = 150; 
    double rl_step = 5; 

    double i, j; 
    double n = rl_start; 
    int count; 

    do 
    { 
     j = ((rl_start) + (rl_step * count)); 
     i = (pow(vs, 2) * j)/pow((rs + j),2); 
     printf("%lf", i); 
     count++; 

    }while(j <= rl_stop); 

    return 0; 
} 

回答

6

你需要使用它之前初始化countint count = 0;

+0

哈,我无法相信我错过了。谢谢你再省30分钟。 – apichel