-1

これをすべてコーディングしましたが、パーセント エラーが出力されません。パーセントをどこに置くべきかよくわかりません。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; 
} 
4

1 に答える 1

0

パーセンテージが必要な場合は、次のようにする必要があります: function=(x* arccos(x)-sqrt(1- pow(x,2)))/RAND_MAX*100;

それはあなたが望むものでなければなりません。

于 2012-11-17T11:15:28.957 に答える