Advertisement
luizaspan

Método de Euler I

Oct 21st, 2015
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define N 100
  5. #define v0 1
  6. #define dt 1e-3
  7.  
  8. #define x0 0
  9. #define t0 0
  10.  
  11. int main(void)
  12. {
  13.     double x = x0, t = t0;
  14.     int i;
  15.  
  16.     for (i = 0; i < N; ++i)
  17.     {
  18.         x += v0*dt;
  19.         t += dt;
  20.         printf("%d %f %f\n", i, t, x);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement