C语言写的打靶修正法
这个程序的A[k+1]怎么会是9562000000000000000000.000000,哪里错了呢?#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream.h>
void main()
{
double A[100],f[1000],p[1000],q[1000],x[1000],y[1000],z[1000],l[1000],m[1000],n[1000];
int i,j,k;
double F1,F2,F3,F4,P1,P2,P3,P4,Q1,Q2,Q3,Q4;
double X1,X2,X3,X4,Y1,Y2,Y3,Y4,Z1,Z2,Z3,Z4;
double L1,L2,L3,L4,M1,M2,M3,M4,N1,N2,N3,N4;
double h=0.05;
/*printf("请输入第一个A的值\n");
cin>>A[0];*/
A[0]=0.2;
for(k=0;k<100;k++)
{
for(j=0;j<1000;j++)
{
f[0]=0,p[0]=0,q[0]=A[k];
F1=h*p[j];
P1=h*q[j];
Q1=h*(p[j]*p[j]-f[j]*q[j]-1);
F2=h*(p[j]+0.5*P1);
P2=h*(q[j]+0.5*Q1);
Q2=h*((p[j]+0.5*P1)*(p[j]+0.5*P1)-(f[j]+0.5*F1)*(q[j]+0.5*Q1)-1);
F3=h*(p[j]+0.5*P2);
P3=h*(q[j]+0.5*Q2);
Q3=h*((p[j]+0.5*P2)*(p[j]+0.5*P2)-(f[j]+0.5*F2)*(q[j]+0.5*Q2)-1);
F4=h*(p[j]+P3);
P4=h*(q[j]+Q3);
Q4=h*((p[j]+P3)*(p[j]+P3)-(f[j]+F3)*(q[j]+Q3)-1);
f[j+1]=f[j]+(1/6.0)*(F1+2*F2+2*F3+F4);
p[j+1]=p[j]+(1/6.0)*(P1+2*P2+2*P3+P4);
q[j+1]=p[j]+(1/6.0)*(Q1+2*Q2+2*Q3+Q4);
if(p[j+1]-p[j]<1e-10) break;
}
if((p[j+1]-1)<1e-6) break;
x[0]=0,y[0]=0,z[0]=A[k],l[0]=0,m[0]=0,n[0]=0;
for(i=0;i<1000;i++)
{
X1=h*y[i];
Y1=h*z[i];
Z1=h*(y[i]*y[i]-x[i]*z[i]-1);
L1=h*m[i];
M1=h*n[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