如何把一个实体模型看成由一系列的质点组成,通过c语言编程把点的质量和坐标输出到.txt文本中?请求指点
[local]2[/local][local]3[/local][local]4[/local]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
typedef struct
{double mess;
double x;
double y;
double z;
}POINT;
POINT std,pers[19640];
main()
{double i,j,k;
int t=0;
FILE *fp;
fp=fopen("D:\\a.txt","wb+");
if (fp==0)
printf("can't open this file");
for (i=0.0;i<=50;i+=0.5)
for(j=0.0;j<=1;j+=0.5)
for(k=0.0;k<=20;k+=0.5)
if(k<=-i+50)
{pers[t++].mess=261.97;
pers[t++].x=i;
pers[t++].y=j;
pers[t++].z=k;
fprintf(fp,"%lf %lf %lf %lf\n",std.mess,std.x,std.y,std.z);
}
fclose(fp);
system("pause");
}
[此贴子已经被作者于2016-10-8 11:49编辑过]