کد:
float F (float c,float b)
{
return (c*c)-b;
}
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <iostream.h>
void main()
{
float a=0,b=2;
float h=0.1;
float y[10];
float t[10];
float y1,t1;
y[0]=1;
float k1,k2,k3,k4;
int m=(b-a)/h;
t[0]=a;
for(int i=0;i<=m;i++)
{
t1=t[i];
y1=y[i];
k1=(h)*F(t1,y1);
k2=h*F(t1+h/2,y1+0.5*k1);
k3=h*F(t1+h/2,y1+0.5*k2);
k4=h*F(t1+h,y1+k3);
y[i+1]=y1+(k1+2*k2+2*k3+k4)/6;
t[i+1]=a+h*(1+i);
if(t[i]==2)
i=m;
cout<<t[i]<<"|"<< k1<<"|"<<k2<<"|"<<k3<<"|"<<k4<<"|"<<y[i]<<endl;
}
getch();
}
تو بورلند يك جواب ميده تو ويژيوال يك جواب ديگه كه هر دو هم اشتباه هستن.
-------------------
-مشكل حل شد. -
-------------------