高手帮忙看看这个程序错在哪里?万分感谢!
可以运行,但是输出的值是一样的..请大神帮忙改下!万分感谢#include<stdio.h>
#include<math.h>
#define PI 3.1415926
double d, lad, dltL,A0,dlty,dltx,R,sita;
int N;
struct complex
{
double read,imag;
};
complex fadd(complex fs1,complex fs2)
{
complex fs3;
fs3.read=fs1.read+fs2.read;
fs3.imag=fs1.imag+fs2.imag;
return fs3;
}
complex Aup(double pointx,double pointy)
{double pointxp,pointyp;
complex rst;
rst.read=0;
rst.imag=0;
lad=400;
lad*=1e-6;
double k=2*PI/lad;
for(int ii=-49;ii<49;ii++)
for(int jj=-49;jj<49;jj++)
{
pointx=ii*R/50;
pointy=jj*R/50;
double r=sqrt((pointyp-pointy)*(pointyp-pointy)+(pointxp-pointx)*(pointxp-pointx)+d*d);
if(sqrt((pointx*pointx)+(pointy*pointy))>=R)continue;
complex lcpx;
lcpx.read=cos(k*r)/r;
lcpx.imag=sin(k*r)/r;
rst=fadd(rst,lcpx);
}
//rst=rst*A0;
rst.read=rst.read*A0;
rst.imag=rst.imag*A0;
return rst;
}
int main()
{
double pointyp,pointxp;
complex AP,IP;
printf("input a0:\n");
scanf("%lf",&A0);
printf("input dltx:\n");
scanf("%lf",&dltx);
printf("input d:\n");
scanf("%lf",&d);
printf("input R:\n");
scanf("%lf",&R);
printf("input dlty:\n");
scanf("%lf",&dlty);
printf("input sita(弧度制):\n");
scanf("%f",&sita);
for(int mm=1;mm<=200;mm++)
for(int ss=1;ss<=200;ss++)
{
pointxp=10+dltx*mm;
pointyp=10+dlty*ss;
AP=Aup(pointxp,pointyp);
IP.read=AP.read*AP.read;
IP.imag=AP.imag*AP.imag;
printf("IP=%.5f+i%.5f\n",IP.read,IP.imag);
}
return 0;
}