| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 537 人关注过本帖
标题:运行出现怪现象
只看楼主 加入收藏
beidou
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-5-16
收藏
 问题点数:0 回复次数:0 
运行出现怪现象

#include "math.h"
#include "stdio.h"
#define c 0
#define d 3.14
#define MAX_N 1000
#define h 0.25*0.3
#define k (2*3.14)/0.3
#define q0 1.2*3.14/2 /*此处改变θ值*/
#define c1shi 9.41
#define c1xu -3.58
#define c2shi 0.44
#define c2xu -2.03
#define Y 0.25
#define v 0.8 /*v=Y/X*/


double maxf(double e)
{double t,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12;
t1=k*h*(cos(e));
t2=cos(k*h);
t3=cos(t1);
t11=(t3-t2)/(sin(e));

t4=cos(2*k*h);
t5=(sin(e))*(sin(e))+3;
t6=(t3-t4)/t5;
t7=t6*(sin(e));
t12=2*t7;

t8=c1shi*t11+c2shi*t12;
t9=c1xu*t11+c2xu*t12;

t10=t8*t8+t9*t9;
t=sqrt(t10);

printf("\n");
printf("q0=%e\n",e);
printf("C1=%e - j%e\n",c1shi,-c1xu);
printf("C2=%e - j%e\n",c2shi,-c2xu);
printf("f=");
printf("%e - j%e\n",t8,-t9);
printf("f(max)=%e\n",t);

return(t);
}


double f(double x,double y,int m,int n)
{double p,g;
double a[8],q[8];

double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13;
q[m]=(2*3.14/8)*m;
q[n]=(2*3.14/8)*n;
t1=(1-v*v)*cos(q[m])*cos(q[m]);
t2=sqrt(1-t1);
a[m]=Y/t2;
t3=(1-v*v)*cos(q[n])*cos(q[n]);
t4=sqrt(1-t3);
a[n]=Y/t4;
t5=a[m]*sin(q[m])-a[n]*sin(q[n]);
t6=a[m]*cos(q[m])-a[n]*sin(q[n]);

g=atan2(t5,t6);

if(m!=n)
{t7=a[m]*a[m]+a[n]*a[n]-2*a[m]*a[n]*cos(q[m]-q[n]);
p=sqrt(t7);
}
else
p=0;

t8=cos(y-g);
t9=k*p*sin(x)*t8;

t10=cos(t9)*sin(x);
t11=maxf(q0)*maxf(q0);
t12=t10*t11;

t13=t11*sin(x);

if(m!=n)
return t12;
else
return t13;
}

double chongjifen(m,n)
int m,n;
{int r,t;
int i,j;
double a,b;
double s,HX,x,y,Q,L,J;
double J1,J2,J3,K1,K2,K3;
r=20,t=20;
a=0,b=2*3.14;

s=(b-a)/t;
J1=0;
J2=0;
J3=0;
for(i=0;i<=t;i++)
{x=a+i*s;
HX=(d-c)/r;
K1=f(x,c,m,n)+f(x,d,m,n);
K2=0;
K3=0;
for(j=1;j<r;j++)
{y=c+j*HX;
Q=f(x,y,m,n);
if(j%2==0)
K2=K2+Q;
else
K3=K2+Q;
}
L=(K1+2*K2+4*K3)*HX/3;
if(i==0||i==t)
J1=J1+L;
else
if(i%2==0)
J2=J2+L;
else
J3=J3+L;
}
J=(J1+2*J2+4*J3)*s/3;
printf("J=%lf\n",J);
return J;
}


main()
{double b[8][8];
int i,j;
int m,n;
for(m=0;m<8;m++)
for(n=0;n<8;n++)
b[m][n]=chongjifen(m,n);

printf("\n");
for(i=0;i<=2;i++)
{for(j=0;j<=2;j++)
printf(" %13.7e ",b[i][j]);
printf("\n");
}


}


#include "stdio.h"
#include "math.h"

double chjifen(m,n,f)
int m,n;
double (*f)();
{int i,j;
double z[8][8];
double s,HX,x,y,Q,L,J;
double J1,J2,J3,K1,K2,K3;
double c=0,d=3.14;
double a=0,b=2*3.14;
int r=20,t=20;

s=(b-a)/t;
J1=0;
J2=0;
J3=0;
for(i=0;i<=t;i++)
{x=a+i*s;
HX=(d-c)/r;
K1=f(x,c)+f(x,d);
K2=0;
K3=0;
for(j=1;j<r;j++)
{y=c+j*HX;
Q=f(x,y);
if(j%2==0)
K2=K2+Q;
else
K3=K2+Q;
}
L=(K1+2*K2+4*K3)*HX/3;
if(i==0||i==t)
J1=J1+L;
else
if(i%2==0)
J2=J2+L;
else
J3=J3+L;
}
J=(J1+2*J2+4*J3)*s/3;

z[m][n]=J;
return z[m][n];

}

帮我看看这个问题怎么解决,多谢!
本程序及时解一个比较复杂的二重积分


搜索更多相关主题的帖子: 现象 运行 
2007-05-16 15:03
快速回复:运行出现怪现象
数据加载中...
 
   



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

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