求VC++编程高手,编辑一个MFC单文档对话框,输入a,c值,用输出数据画曲线图!定有重谢!!!
程序代码如下:#include<stdio.h>#include<math.h>FILE*fp;doublefun1(doubleh,doublex,doublea,do...
程序代码如下:
#include<stdio.h>
#include<math.h>
FILE *fp;
double fun1(double h,double x, double a, double c)
{
double s;
s=((h*h+x*x-a*a-c*c)+sqrt((x*x+h*h)*(x*x+h*h)+(a*a-c*c)*(a*a-c*c)-2*(a*a-c*c)*(x*x-h*h)))/2.0;
return s;
}
double fun2(double h, double x, double a, double c)
{
double t;
t=x*(1+(x*x+h*h-a*a+c*c)/(sqrt((x*x+h*h)*(x*x+h*h)+(a*a-c*c)*(a*a-c*c)-2*(a*a-c*c)*(x*x-h*h))));
return t;
}
void main()
{
int i;
double h,x,a,c,u,u1,p1=1.0,p2=100.0,ps;
double A[3]={0.005,0.01,0.05},C[3]={3.0,5.0,8.0};
double *P,*Q;
fp=fopen("ps.txt","w");
P=A;
Q=C;
for(h=10.0;h<=50.0;h+=20.0)
{
for(x=-30.0;x<=30.0;x++)
{
for(i=0;i<=2;i++)
{
a=*(P+i);
c=*(Q+i);
//printf("%f %f %f %f \n",h,x,a,c);
u=fun1(h,x,a,c);
u1=fun2(h,x,a,c);
ps=p1*(1+((2*(p1-p2)*a*c)/((a-c)*(p2*a+p1*c)))*(1-sqrt((c*c+u)/(a*a+u))-x*u1*((a*a-c*c)/(2*sqrt(c*c+u)*pow(a*a+u,1.5)))));
printf("%f %f %f %f\n",h,x,a,ps);
// fprintf(fp,"%f %f\n",x,ps);
}
fprintf(fp,"%f %f\n",x,ps);
}
}
fclose(fp);
} 展开
#include<stdio.h>
#include<math.h>
FILE *fp;
double fun1(double h,double x, double a, double c)
{
double s;
s=((h*h+x*x-a*a-c*c)+sqrt((x*x+h*h)*(x*x+h*h)+(a*a-c*c)*(a*a-c*c)-2*(a*a-c*c)*(x*x-h*h)))/2.0;
return s;
}
double fun2(double h, double x, double a, double c)
{
double t;
t=x*(1+(x*x+h*h-a*a+c*c)/(sqrt((x*x+h*h)*(x*x+h*h)+(a*a-c*c)*(a*a-c*c)-2*(a*a-c*c)*(x*x-h*h))));
return t;
}
void main()
{
int i;
double h,x,a,c,u,u1,p1=1.0,p2=100.0,ps;
double A[3]={0.005,0.01,0.05},C[3]={3.0,5.0,8.0};
double *P,*Q;
fp=fopen("ps.txt","w");
P=A;
Q=C;
for(h=10.0;h<=50.0;h+=20.0)
{
for(x=-30.0;x<=30.0;x++)
{
for(i=0;i<=2;i++)
{
a=*(P+i);
c=*(Q+i);
//printf("%f %f %f %f \n",h,x,a,c);
u=fun1(h,x,a,c);
u1=fun2(h,x,a,c);
ps=p1*(1+((2*(p1-p2)*a*c)/((a-c)*(p2*a+p1*c)))*(1-sqrt((c*c+u)/(a*a+u))-x*u1*((a*a-c*c)/(2*sqrt(c*c+u)*pow(a*a+u,1.5)))));
printf("%f %f %f %f\n",h,x,a,ps);
// fprintf(fp,"%f %f\n",x,ps);
}
fprintf(fp,"%f %f\n",x,ps);
}
}
fclose(fp);
} 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询