Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- #include <iostream>
- double f(double x,double y){ // ôóíêöèÿ ïåðâîé ïðîèçâîäíîé
- return 5*x*x + 6*x*x;
- }
- int main(){
- double x,y,h;// x0, y0, øàã ñîîòâåòñòâåííî
- int n; // êîëè÷åñòâî èòòåðàöèé
- cout<<"x0=";
- cin>>x;
- cout<<"y0=";
- cin>>y;
- cout<<"h=";
- cin>>h;
- cout<<"n=";
- cin>>n;
- double yi=y;
- double xi=x;
- for (int i = 0;i<n;i++){
- yi+= h*f(x,y);
- xi+= h;
- y+=0.5*h*(f(x,y)+f(xi,yi));
- x+=h;
- }
- cout<<"x"<<n<<"="<<x<<endl;
- cout<<"y"<<n<<"="<<y<<endl;
- cout<<"f="<<f(x,y);
- return 0;
- }
RAW Paste Data