fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. void test( float dt, int steps )
  5. {
  6. float x = 100.0f;
  7. float v = 0;
  8. for ( int i = 0; i < steps; i++ )
  9. {
  10. v = v - .1f * x * dt;
  11. x = x + v * dt;
  12. }
  13. printf("%g\n", x);
  14. };
  15.  
  16. int main(int argc, char **argv) {
  17.  
  18. test( 0.01, 100000000 );
  19. printf("%g\n", 100.0f*cos(0.01*100000000.0/sqrt(10.0f)));
  20. return 0;
  21. }
Success #stdin #stdout 1.05s 2896KB
stdin
Standard input is empty
stdout
10.9255
23.5861