Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <memory>
- using namespace std;
- double F(double x, double y) {
- return 3 * sin(2 * y) + x;
- }
- int main(int argc, char** argv)
- {
- double a = 0; double b = 1; double h = 0.1;
- double n = ((b - a) / h) + 1;
- unique_ptr<double[]> X(new double[(int)n]);
- unique_ptr<double[]> Y(new double[(int)n]);
- X[0] = a; Y[0] = 2;
- for (int i = 1; i <= n - 1; i++) {
- X[i] = a + i * h;
- Y[i] = Y[i - 1] + h * F(X[i - 1], Y[i - 1]);
- }
- for (int i = 0; i <= n - 1; i++) {
- cout << "X[" << i << "]=" << X[i] << " ";
- }
- cout << std::endl;
- for (int i = 0; i <= n - 1; i++) {
- cout << "Y[" << i << "]=" << Y[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement