各位大虾,有个问题小弟想请教:下面这个程序的错误出在什么地方?请哪为帮我指出,不胜感激,我看了很久了,不会改
#include<iostream>
using namespace std;
#include<stdio.h>
#include<string.h>
# define SIZE 221
struct canshu_type
{int bianhao;
int a;
float y;
float x;
int b;
int c;
char kk[100];
}can[SIZE];
void main()
{ int i;
FILE *fp1,*fp2,*fp3;
fp1=fopen("1-bb.txt","r");
for(i=0;i<SIZE;i++)
{fread (&can[i],sizeof(struct canshu_type),1,fp1);}
fp2=fopen("1.lge","w");
fp3=fopen("1.lxy","w");
float pt_y[10000],pt_x[10000];
int pt_2[10000];
int a,j,ss,ps1,pt;
int shuhao=1;
int Fpao=2329,Epao=2549;
int x,x1,y,s,s1;
float xx,xxx,yy,yyy;
for(i=0;i<SIZE;i++)
{
int m;
m=can[i].bianhao;
{
pt_y[m]=can[i].y;
pt_x[m]=can[i].x;
pt_2[m]=can[i].c;
}
ss=(shuhao-1)*2500;
fprintf(fp2,"* LIBRI GE 01 XS20,XM10,$\n");
fprintf(fp2," (PS %s-PS %s)=(X1,I1),$\n",ss+1,ss+4000);
fprintf(fp2," (PT%s-PT %s)=(X1,I0),$\n",Fpao,Epao);
fprintf(fp2," (PT%s-PT %s)=T384((%s-%s),\n",Fpao,Epao,ss+1,ss+48);
fprintf(fp2," (%s-%s),\n",ss+501,ss+548);
fprintf(fp2," (%s-%s),\n",ss+1001,ss+1048);
fprintf(fp2," (%s-%s),\n",ss+1501,ss+1548);
fprintf(fp2," (%s-%s),\n",ss+2001,ss+2048);
fprintf(fp2," (%s-%s),\n",ss+2501,ss+2548);
fprintf(fp2," (%s-%s),\n",ss+3001,ss+3048);
fprintf(fp2," (%s-%s)),$\n",ss+3501,ss+3548);
for ( i=Fpao;i<=Epao-1;i++)
{
ps1= pt_2[i];
if ( ps1==0)
{ps1=300;}
fprintf(fp2," PT%s=(PS%3d,PAS0),\n",i,ps1) ;
}
ps1= pt_2[Epao];
if ( ps1==0)
{ps1=300;}
fprintf(fp2," PT%s=(PS%3d,PAS0),$\n",Epao,ps1) ;
fprintf(fp3,"* LIBRI XY 01 FAC20.0,\n");
y=2+(shuhao-1)*10;
s=(shuhao-1)*2500;
for(j=1;j<=8;j++)
{
x=0;
for(i=1;i<=250;i++)
{
x=x+1;
s=s+1;
x1=x+1;
s1=s+1;
fprintf(fp3," S%6d,X%5d,Y%4d,S%6d,X%5d,Y%4d,\n",s,x,y,s1,x1,y);
x=x1;
s=s1;
}
y=y+2;
} ;
for ( i=Fpao;i<=Epao;i++)
{
xx=pt_x[i];
xxx=xx;
yy=pt_y[i];
yyy=yy/2;
if (xx==0){xxx=300;
yyy=y;};
fprintf(fp3," PT%s,X %6.1f,Y %6.1f,\n",i,xxx,yyy) ;};
}
fclose(fp1);
fclose(fp2);
fclose(fp3);
}
程序的意思是想实现数据的转换,由原始的数据文件生成另外两个文件
[此贴子已经被作者于2007-5-19 12:00:52编辑过]