/**********************************************/ /* randam_walk.cxx ランダムウォークプログラム  */ /*********************************************/ #include #include #include #include using namespace std; //関数のプロトタイプ宣言 double frand(void) ;//実数乱数 //ファイル書き込み char fout[20]="randam_walk.txt"; ofstream ofs(fout); /********************************/ /* main()関数 */ /********************************/ int main(int argc, char *argv[]) { int n; //試行回数 int i; //繰り返し制御変数 int seed; //乱数の種 double x=0, y=0; //点の座標 //試行回数nの初期化 if(argc<3){//引数の指定がない cout << "使い方 hello (試行回数n) (乱数の種)\n"; exit(1); } if((n=atoi(argv[1]))<=0){ cout << "試行回数nが不正です\n"; exit(1); } if((seed=atoi(argv[2]))<=0){ cout <<"乱数の種が不正です.\n"; exit(1); } //乱数の初期化 srand(seed); ofs << "x"<<","<<"y"<<"\n"; ofs << x<<","<