#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <mem.h>
#include <dos.h>
main()
{
FILE *in,*out;
char outname[20],inname[20];
char str[85],x[20],y[20],h[20],dh[20],s[50];
float n1[800],h1[800];
float n2,e2,h2,h3,dlth;
int i=0,j=0,num;
printf("please input the name of inname data:");
scanf("%s",inname);
if((in=fopen(inname,"r"))==NULL)
{printf("cannot open the file of %s\n",inname);
exit(0);
}
printf("please input the name of outname data:");
scanf("%s",outname);
if((out=fopen(outname,"w"))==NULL)
{printf("cannot open the file of %s\n",outname);
exit(0);
}
while(!feof(in))
{
fgets(str,80,in);
if(str[0]=='b')
{for(i=0;i<7;i++)
dh[i]=str[i];
dh[i]='\0';
for(i=8,j=0;str[i]!=',';i++,j++)
x[j]=str[i];
x[j]='\0';i=i+1;
for(j=0;str[i]!=',';i++,j++)
y[j]=str[i];
y[j]='\0';i=i+1;
for(j=0;str[i]!=',';i++,j++)
h[j]=str[i];
h[j]='\0';i=i+1;
for(j=0;str[i]!='\0';i++,j++)
s[j]=str[i];i=i+1;
s[j]='\0';
n2=(double)atof(y);e2=(double)atof(x),h2=(double)atof(h);
if(abs(e2)<0.5)
{
fputs(dh,out);
fprintf(out,",%1.2f,%1.2f,%1.2f,",e2,n2,h2);
fputs(s,out);
}
}
}
fclose(in);
fclose(out);
}
评论0