fork download
  1. #include <stdio.h>
  2.  
  3. typedef double real;
  4.  
  5. real sine( real x ){
  6. real s1, s=x, r=x, n=2;
  7. x *= x;
  8. do{ s1 = s;
  9. s += r=-r*x/(n*n+n);
  10. n += 2;
  11. } while( s != s1 );
  12. return s;}
  13.  
  14. int main() {
  15.  
  16. real a=0, b= 1;
  17. volatile real ostatniX, x, h;
  18. int n, i;
  19.  
  20. for( n=10; n<=1000000000; n *= 10 ) {
  21. h=(b-a)/n;
  22. x=a;
  23. for( i=0; i<=n; i++ ) {
  24. // printf("%0.15f %0.15f %f0.15\n" , x, sine(x), sine(a + i*h ) );
  25. ostatniX = x;
  26. x += h; }
  27. x = ostatniX;
  28. printf("%12d %0.15f %0.15f %0.15f\n" , n, x, sine(x), sine(a + n*h ));
  29. }
  30.  
  31. return 0;
  32. }
  33. }
  34.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:33: error: expected declaration before ‘}’ token
stdout
Standard output is empty