SHARE
TWEET

Untitled

a guest May 24th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top