#include #include int main() { double dt = 0.0001; double g = 9.8; double vx, vy, x, y, t, ax, ay; FILE *f; f = fopen("dati.txt", "w"); if (f == NULL) { fprintf(stderr, "Impossibile aprire dati.txt\n"); return -1; } vx = 0; vy = 0; x = 5; y = 0; t = 0; while (t < 10) { fprintf(f,"%f %f %f\n", t, x, y); x = x + vx * dt; y = y + vy * dt; ay = - g * (x*x)/(x*x + y * y) - (vx * vx + vy * vy) * y / (x * x + y * y); ax = g * (x*y)/(x*x + y * y) - (vx * vx + vy * vy) * x / (x * x + y * y); vy = vy + ay * dt; vx = vx + ax * dt; t = t + dt; } fclose(f); return 0; }