Kod: Zaznacz cały
#include<iostream>
using namespace std;
void lve(float y[2], float h, float a, float b,float c,float d) {
float z;
z=h*(a-b* y[1])*y[0]+y[0];
y[1]= h*(-c+d* y[0])*y[1]+y[1];
y[0]=z;
}
void F(float y[2], float a, float b,float c,float d, float t, int steps) {
float h=t/steps;
y[0]=5;
y[1]=2;
for (int i=0; i<steps; i++) lve(y,h,a,b,c,d);
}
int main() {
float y[2]={.5,1};
float h=0.01,a=3, b=2,c=2,d=3;
for (int i=0; i<=2000; i++) {
lve(y,h,a,b,c,d);
cout << i*h << " " << y[0] << endl;
cout << i*h << " " << y[1] << endl;
}
float t=5;
int steps=500;
F(y,a,b,c,d,t,steps);
cout << "F[0](" << t << ")=" << y[0] << endl;
cout << "F[1](" << t << ")=" << y[1] << endl;
system("pause");
}