当前位置:百问家>生活百科>c语言----编程

c语言----编程

2024-10-31 21:39:03 编辑:zane 浏览量:573

c语言----编程

的有关信息介绍如下:

c语言----编程

#include "stdio.h"#include "math.h"#include "malloc.h"#define G 6.67 /*万有引力常数(G:m^3/(kg*s^2))*/main (){ FILE *fp; int i; double ra,rc,fia,fic; double *Vxz,*Vzz; double p,b,h,q; //double变量用%lf输入可以用%f或%lf输出 printf("\n***********A program of Gravitytabular***********\n"); printf("Remain Dentisity is p\n"); printf("Breadth is b\n"); printf("Burial Depth is h\n"); printf("Dip is q\n"); printf("Please enter the parameters:\n"); scanf("%lf%lf%lf%lf",&p,&b,&h,&q); //变量的顺序和上面提示的顺序不吻合 Vxz=(double *)calloc(50,sizeof(double)); Vzz=(double *)calloc(50,sizeof(double)); fp=fopen("answer2.txt","w"); for(i=0;i<=49;i++) { ra=sqrt(pow((i+b),2)+pow(h,2)); rc=sqrt(pow((i-b),2)+pow(h,2)); fia=atan((b+i)/h); fic=atan((i-b)/h); Vxz[i]=2*G*p*sin(q)*(sin(q)*log(rc/ra)+cos(q)*(fia-fic)); Vzz[i]=2*G*p*sin(q)*(sin(q)*(fia-fic)-cos(q)*log(rc/ra)); Vxz[i]=10*Vxz[i]; Vzz[i]=10000*Vzz[i]; fprintf(fp,"Vxz=%10.4f Vzz=%10.4f\n",Vxz[i],Vzz[i]); } fclose(fp); printf("\n end of transform.\n");}//如果还有疑问我们可以交流交流//祝你学习进步

版权声明:文章由 百问家 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.baiwenjia.com/life/191950.html
热门文章