使用弧余弦函数尝试输出 3 个不同数量的百分比错误



我编码了所有这些,但它不会输出我的任何百分比错误,我不太确定将百分比放在哪里?假设输出 3 个不同的数字,但由于此错误,我什至无法输出我不知道我尝试将所有内容更改为浮点数和整数,但 % 的错误消息使函数过载?

double dRandom()
{
    return double(rand()/RAND_MAX); 
}
int main()
{
    int loop_count=100, count=0;
    int result=0; 
    float x=dRandom(); 
    double y=dRandom(); 
    float arccos (float x);
    float function=0; 
    srand(time(NULL)); 
    for(int i=1; i<4;++i) 
    { 
        for (int k=1; k<= loop_count; ++k) 
        { 
            function= (x* arccos(x)-sqrt(1- pow(x,2)))%RAND_MAX;//this line is where i'm not sure how to add the percent sign in correctly 
        }  
    } 
    if(x<y)  
        cout<<result; 
    return 0; 
} 

如果你想要百分比,它应该是这样的: function=(x* arccos(x)-sqrt(1- pow(x,2)))/RAND_MAX*100;

它应该是你想要的东西。

最新更新