C/C++の宿題を片付けます 119代目
■ このスレッドは過去ログ倉庫に格納されています
0112デフォルトの名無しさん
2008/12/05(金) 22:42:56#include <stdio.h>
#include <math.h>
#include <unistd.h>
#define sticklen 0.8
#define PI 3.1416
double x,y;double theta,vtheta,atheta;const double t = 0.2;
void init(void)
{ printf("初期振れ角:");
scanf("%lf",&theta);
vtheta = 0.0;
atheta = -(9.8/sticklen)*sin(PI*theta/180.0);
x = sticklen*sin(PI*theta/180.0);
y = -sticklen*cos(PI*theta/180.0);}
void update(void){
vtheta += atheta*t;
theta += vtheta*t;
atheta = -(9.8/sticklen)*sin(PI*theta/180.0);
x = sticklen*sin(PI*theta/180.0);
y = -sticklen*cos(PI*theta/180.0);}
int main()
{ FILE * fpw; int i;
fpw = popen("gnuplot -persist","w"); init();
fputs("set size square\n", fpw);
fputs("set xrange [-5:5]\n", fpw);
fputs("set yrange [-5:5]\n", fpw);
fprintf(fpw, "set parametric\n");
for (i = 0; i < 200; ++i) {
fprintf(fpw, "plot [0:2*pi] cos(t) / 4.0 + %f , sin(t) / 4.0 + %f\n", x, y);
fprintf(fpw, "pause %f\n", t); update(); }
return 0;}
popenでいいらしいので作った、でもパイプ接続ってわざわざ言われてたならこれじゃまただめだし食らうんだろうなw
■ このスレッドは過去ログ倉庫に格納されています