fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. double sin (double x, double e) {
  5. double k, a = x;
  6. double s = x;
  7. int n=1;
  8. while (abs(a) > e) {
  9. k = - x * x / (2 * n * (2 * n + 1));
  10. a *= k;
  11. s += a;
  12. n++;
  13. }
  14. return s;
  15. }
  16. int main () {
  17. double x, e;
  18. cin >> x >> e;
  19. cout << endl << sin(x, e);
  20. }
Time limit exceeded #stdin #stdout 5s 3456KB
stdin
Standard input is empty
stdout
Standard output is empty