| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 323 人关注过本帖
标题:这个程序错在哪里帮忙看下,万分感谢!!
取消只看楼主 加入收藏
光学衍射
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-11-15
收藏
 问题点数:0 回复次数:0 
这个程序错在哪里帮忙看下,万分感谢!!
可以运行,但是输出的值是一样的,请大神看看,万分感谢!
#include<stdio.h>
#include<math.h>
#define PI 3.1415926

double d, lad, dltL,A0,dlty,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 pointx1,double pointx2,double pointy)
{
    complex rst;
    rst.read=0;
    rst.imag=0;
    lad=400;  
    lad*=1e-6;
    double k=2*PI/lad;           
    N=(int)((pointx2-pointx1)/dltL);
    for(int ii=0;ii<N;ii++)
    {
        complex lcpx;
        lcpx.read=cos(k*dltL*ii*sin(sita));
        lcpx.imag=sin(k*dltL*ii*sin(sita));
        rst=fadd(rst,lcpx);
        
    }
    //rst=rst*A0;
    rst.read=rst.read*A0;
    rst.imag=rst.imag*A0;
    return rst;
}


complex SUBY(double pointy)
{
    double pointx1, pointx2;
    complex y;
    y.read=0;
    y.imag=0;
    int j;
    double a[10]={0.00,0.03,0.07,0.10,0.13,0.15,0.18,0.20,0.23,0.25};
 double b[10]={0.02,0.06,0.09,0.11,0.14,0.17,0.19,0.22,0.24,0.27};
for(j=0;j<10;j++)
{pointx1=a[j];
pointx2=b[j];
        y.read+=Aup(pointx1,pointx2,pointy).read;
        y.imag+=Aup(pointx1,pointx2,pointy).imag;
    }
    return y;
}

 int main()
{
    double pointy;
    double pointy1=10.0;
    double pointy2=50;        
    complex AP,IP;
    int G;
   
    printf("input a0:\n");
    scanf("%lf",&A0);
    printf("input dltL:\n");
    scanf("%lf",&dltL);
    printf("input d:\n");
    scanf("%lf",&d);
    printf("input dlty:\n");
    scanf("%lf",&dlty);
    G=(int)((pointy2-pointy1)/dlty);
    printf("input sita(弧度制):\n");
       scanf("%f",&sita);
    for(int k=1;k<=G;k++)
    {
        pointy=10+dlty*k;
        AP=SUBY(pointy);
        IP.read=AP.read*AP.read;
        IP.imag=AP.imag*AP.imag;
        
        printf("IP=%.5f+i%.5f\n",IP.read,IP.imag);
    }
    return 0;
}
搜索更多相关主题的帖子: 感谢 
2010-11-24 10:14
快速回复:这个程序错在哪里帮忙看下,万分感谢!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029904 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved