www.pudn.com > c.rar > HEATDATA.C, change:1997-08-18,size:2536b


#include "stdio.h" 
#include "math.h" 
#define MAX 4800 
struct stress{ 
float node_x; 
float node_y; 
float node_z; 
}number[MAX]; 
/*****************************************/ 
void main() 
{ 
struct stress *p_number; 
int t[14],nodenum,i,j,point,numnp,num; 
float ver[50]; 
char ch,s1[80],s2[80],s3[80],cha1[80],cha2[80]; 
FILE *fp1,*fp2,*fp3; 
p_number=number; 
clrscr(); 
printf(" \t\t Heat data analysis...\n"); 
printf("Please enter ele_node_data filename:(*.)"); 
scanf("%s",s1); 
if((fp1=fopen(s1,"r"))==NULL){ 
	printf("\n\n\aCannot open the file or file not find!\n"); 
	exit(1); 
	} 
for(i=0;i<=18;i++) 
fscanf(fp1,"%c",&ch); 
fscanf(fp1,"%f%d",&ver[0],&nodenum); 
for(i=0;i<=13;i++) 
fscanf(fp1,"%d",&t[i]); 
fscanf(fp1,"%f",&ver[0]); 
for(i=0;i<=6;i++) 
fscanf(fp1,"%d",&t[i]); 
fscanf(fp1,"%f%f%f",&number[0].node_x,&number[0].node_y,&number[0].node_z); 
fscanf(fp1,"%d%f%d%d",&t[0],&ver[0],&t[1],&t[2]); 
for(j=1;j<nodenum;j++) 
{ 
for(i=0;i<=6;i++) 
fscanf(fp1,"%d",&t[i]); 
	{ 
	  fscanf(fp1,"%f%f%f",&number[j].node_x,&number[j].node_y,&number[j].node_z); 
	  fscanf(fp1,"%d%f",&t[0],&ver[0]); 
	  } 
} 
printf("Please enter heat data filename:(*.l)"); 
scanf("%s",s2); 
if((fp2=fopen(s2,"r"))==NULL){ 
	printf("\n\n\aCan not open the file or file not find!\n"); 
	exit(1); 
	} 
if(strstr(s2,".l")==0) 
	{ 
	printf("\n\t\aFile name error!\n"); 
	exit(1); 
	} 
printf("Reading datas......\n"); 
printf("\t****************************\n"); 
printf("\tThe model have %d nodes...\n",nodenum); 
printf("\t****************************\n"); 
printf("\nPlease enter save filename:(*.dat)"); 
scanf("%s",s3); 
if((fp3=fopen(s3,"w"))==NULL){ 
	printf("\aCan not open the file!\n"); 
	exit(1); 
} 
printf("Saving datas..."); 
for(i=1;i<=535;i++) 
fscanf(fp2,"%c",&ch); 
fscanf(fp2,"%d",&numnp); 
point=0; 
for(;;) 
{ 
point=point+1; 
fscanf(fp2,"%s",cha1); 
fscanf(fp2,"%s",cha2); 
if(fmod(point,100)==0.0)printf("."); 
if((strcmp(cha1,"NUMBER")==0&&strcmp(cha2,"TEMPERATURE")==0)||(strcmp(cha1,"NODE")==0&&strcmp(cha2,"NUMBER")==0))break; 
} 
if(strcmp(cha2,"NUMBER")==0) 
fscanf(fp2,"%s",cha2); 
for(i=1;i<=numnp;i++) 
{ 
fscanf(fp2,"%d",&num); 
fprintf(fp3,"%d",num); 
fprintf(fp3,"\t%e %e %e ",p_number->node_x,p_number->node_y,p_number->node_z); 
p_number++; 
for(;;) 
	{ 
	fscanf(fp2,"%c",&ch); 
	if(ch=='D')break; 
	fprintf(fp3,"%c",ch); 
	} 
fputc('e',fp3); 
for(j=1;j<=3;j++) 
	{ 
	fscanf(fp2,"%c",&ch); 
	fprintf(fp3,"%c",ch); 
	if(j==3)fprintf(fp3,"\n"); 
	} 
} 
fclose(fp1); 
fclose(fp2); 
fclose(fp3); 
return; 
}