Skip to content

Instantly share code, notes, and snippets.

@richardwei6
Last active December 19, 2020 20:56
Show Gist options
  • Save richardwei6/2ea7b40209d24044e57b0244e9940ff3 to your computer and use it in GitHub Desktop.
Save richardwei6/2ea7b40209d24044e57b0244e9940ff3 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
double dydx(double x, double y){
return x+y;
}
int main(){
double x, y, h, endX;
cin >> x >> y >> h >> endX;
while (!(abs(x-endX) < 0.001)){
y = y + h*dydx(x,y);
x = x + h;
cout << x << " " << y << endl;
}
cout << "ans - " << x << " " << y << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment