unsigned int calc_data(unsigned int n_step, double h, double t[], double x[], double y[]){ int i; //int n_step; //double h; //初期条件 //t[0] = 0.0; //x[0] = 2.0; //y[0] = 0.0; //h = 0.002; //刻み幅 //n_step = 7500; //ステップ数 //オイラー法の計算 for(i = 0; i <= n_step; i++){ y[i+1] = y[i] + h*yfunc(x[i], t[i]); x[i+1] = x[i] + h*xfunc(y[i], t[i]); t[i+1] = t[i] + h; } //計算結果の表示 for(i = 0; i <= n_step; i += 50) //printf("%lf | %lf\n", t[i], x[i]); return n_step; }
/*ARGSUSED1*/ void key (unsigned char key, int x, int y) { switch (key) { case 'b': bfunc(); break; case 'c': cfunc(); break; case 'l': lfunc(); break; case 't': tfunc(); break; case 'f': ffunc(); break; case 'n': nfunc(); break; case 'u': ufunc(); break; case 'U': Ufunc(); break; case 'p': pfunc(); break; case 'P': Pfunc(); break; case 'w': wfunc(); break; case 'x': xfunc(); break; case 'X': Xfunc(); break; case 'y': yfunc(); break; case '\033': exit(EXIT_SUCCESS); break; default: break; } }