为什么我没有正确的ro答案?

Why i don't have a correct answer for ro?

本文关键字:ro 答案 为什么      更新时间:2023-10-16
#include<stdio.h>
#include <math.h>
int main()
{
    float pb;
    float N;
    float ro;
    float nb;
    printf(" Now we will find the number of charges and users n n n ");
    printf(" Please enter the probability n ");
    printf(" The probability is ");
    scanf("%f",&pb);

    printf("n n Please enter the number of circuits N n");
    printf("The number is");
    scanf("%f",&N);
    while ( pb>0.01 )
    {
        pb=1/(1+N/(ro*pb));
        ro=ro+0.01;
    }
    printf("%f",ro);
}

至少需要初始化不需要从用户读取的所有变量。现在,您正在使用一些"随机"值进行数学运算。

pb=1/(1+N/(ro*pb));

在上面的程序语句中使用ro,并且它没有初始化,所以你的计算没有按照预期结束。