这是一道计算机3J编程的题目
#include<stdio.h>#include<memory.h>
#include<string.h>
#include<stdlib.h>
#define MAX 100
typedef struct
{
char dm[5];
char mc[11];
int dj;
int sl;
long je;
}PRO;
PRO sell [MAX];
void ReadDat();
void WriteDat();
void SortDat()
{
int i,j;
PRO temp;
for(i=0;i<99;i++)
for(j=i+1;j<100;j++)
if(strcmp(sell[i].mc,sell[j].mc)>0)
{
temp=sell[i];
sell[i]=sell[j];
sell[j]=temp;
}
else if(strcmp(sell[i].mc,sell[j].mc)==0)
if(sell[i].je>sell[j].je)
{
temp=sell[i];
sell[i]=sell[j];
sell[j]=temp;
}
}
void main()
{
memset(sell,0,sizeof(sell));
ReadDat();
SortDat();
WriteDat();
}
void ReadDat()
{
FILE *fp;
char str[80],ch[11];
int i;
fp=fopen("IN.DAT","r");
for(i=0;i<100;i++);
{
fgets(str,80,fp);
memcpy(sell[i].dm,str,4);
memcpy(sell[i].mc,str,4);
memcpy(ch,str+14,4);ch[4]=0;
sell[i].dj=atoi(ch);
memcpy(ch,str+18,5);ch[5]=0;
sell[i].sl=atoi(ch);
sell[i].je=(long)sell[i].dj*sell[i].sl;
}
fclose(fp);
}
void WriteDat()
{
FILE *fp;
int i;
fp=fopen("OUT.DAT","w");
for(i=0;i<100;i++)
{
fprintf(fp,"%s %s %4d %5d %10ld\n",sell[i].dm,sell[i].mc,sell[i].dj,sell[i].sl,sell[i].je);
}
fclose(fp);
}
我用VC6.0运行,没有输出结果,这是为什么呢?怎么样才有输出结果?