Advertisement
Guest User

Untitled

a guest
May 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. const int INTEGRAL_COUNT = 10;
  2. const int Y_START = 0;
  3. const int Y_END = 1;
  4. const int X_START = -1;
  5. const int X_END = 1;
  6. const double INTEGRAL_STEP = 0.1;
  7.  
  8. void czekaj(int milis);
  9. double integral(double k, double x, double y) {
  10. return sin(k*x) / x * x + y * y + sqrt(k);
  11. }
  12.  
  13. start = clock();
  14. double *integrals = new double[INTEGRAL_COUNT];
  15. for (int k = 0; k<INTEGRAL_COUNT; k++) {
  16. integrals[k] = 0;
  17. for (double y = Y_START; y <= Y_END; y += INTEGRAL_STEP) {
  18. for (double x = X_START; x <= X_END; x += INTEGRAL_STEP) {
  19. integrals[k] += integral(k + 1, x, y)*INTEGRAL_STEP*INTEGRAL_STEP;
  20. }
  21. }
  22. }
  23.  
  24. cout << "time: " << clock() - start << endl;
  25.  
  26. for (int k = 0; k<INTEGRAL_COUNT; k++) {
  27. cout << "dla k = " << k + 1 << " wartosc calki wynosi: " << integrals[k] << endl;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement