Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. # include <stdio.h>
  2. # include <stdlib.h>
  3. # include <math.h>
  4.  
  5. int main(void)
  6. {
  7. double g=10;
  8. double x0=0.,y0=0.,v0,w0,t=0.,dt;
  9. double x1,y1,v1,w1; // step-by-step
  10. double x2,y2; // formula
  11. int i,n;
  12. FILE * A;
  13. A = fopen("sravn.txt","w");
  14. scanf("%lf",&v0);
  15. scanf("%lf",&w0);
  16. scanf("%lf",&x0);
  17. scanf("%lf",&y0);
  18. scanf("%lf",&dt);
  19. scanf("%d",&n);
  20. v1=v0;
  21. w1=w0;
  22. x1=x0;
  23. x2=x0;
  24. y1=y0;
  25. y2=y0;
  26. for(i=0;i<n;i++)
  27. {
  28. fprintf(A,"%lf %lf %lf %lf %lf\n",t,x1,y1,x2,y2);
  29. t=t+dt;
  30. x2 = v0*t + x0;
  31. y2 = y0 + w0*t - g*t*t*(0.5);
  32. w1 = w1 - g*dt;
  33. x1 = x1 + v1*dt;
  34. y1 = y1 + w1*dt;
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement