Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int INTEGRAL_COUNT = 10;
- const int Y_START = 0;
- const int Y_END = 1;
- const int X_START = -1;
- const int X_END = 1;
- const double INTEGRAL_STEP = 0.1;
- void czekaj(int milis);
- double integral(double k, double x, double y) {
- return sin(k*x) / x * x + y * y + sqrt(k);
- }
- start = clock();
- double *integrals = new double[INTEGRAL_COUNT];
- for (int k = 0; k<INTEGRAL_COUNT; k++) {
- integrals[k] = 0;
- for (double y = Y_START; y <= Y_END; y += INTEGRAL_STEP) {
- for (double x = X_START; x <= X_END; x += INTEGRAL_STEP) {
- integrals[k] += integral(k + 1, x, y)*INTEGRAL_STEP*INTEGRAL_STEP;
- }
- }
- }
- cout << "time: " << clock() - start << endl;
- for (int k = 0; k<INTEGRAL_COUNT; k++) {
- cout << "dla k = " << k + 1 << " wartosc calki wynosi: " << integrals[k] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement