C/C++の宿題片付けます 131代目at TECH
C/C++の宿題片付けます 131代目 - 暇つぶし2ch170:デフォルトの名無しさん
09/10/21 19:14:41
>>162 合ってるかどうか自信は無い
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

double uniformed_rand(void)
{
return (double)rand()/(RAND_MAX+1);
}

int main(void)
{
double theta, phi;
double r=5.0, x, y, z;
int i;

for(i=0;i<100;i++)
{
phi=asin(uniformed_rand()*2-1);
theta=uniformed_rand()*2*M_PI;
x=r*cos(theta)*cos(phi);
y=r*sin(theta)*cos(phi);
z=r*sin(phi);
printf("x=%f y=%f z=%f\n", x, y, z);
}

return 0;
}


次ページ
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch