| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 319 人关注过本帖
标题:大家都来看看啊帮个忙
只看楼主 加入收藏
huaiying2004
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-1-9
收藏
 问题点数:0 回复次数:0 
大家都来看看啊帮个忙

//memset(fenxianModo, 0, sizeof(fenxianModo));

WriToFILE(in0, out0);
WriModo(in1, out1, out11, in0);
WriModo(in2, out2, out22, in0);
WriModo(in3, out3, out33, in0);
fcloseall();
}

void WriModo(FILE *in1, FILE *out1, FILE *out2, FILE *in0)
{
BYTE BS;
BYTE word[100];
BYTE addr;
FENGXIANIDX u1, u2;

memset(u1.address, 0, 50);
memset(u2.address, 0, 50);

u1.num = 0;
u2.num = 0;
while(!feof(in1))
{
fseek(in0, 0, SEEK_SET);
BS = GetBS(in1);
if(BS==0xFF)
break;
Getline(in1, word);
addr = FindFILE(word, in0);
if(addr == 0xFF)
{
printf("\n%s", word);
getch();
}
if(BS=='A')
{
u1.address[u1.num++] = addr;
}
else if(BS=='C')
{
u2.address[u2.num++] = addr;
}
else
{
printf("!!ERROR");
getch();
}
}
u1.address[u1.num] = 0;
u2.address[u2.num] = 0;
fputc(u1.num, out1);
fwrite(u1.address, u1.num, 1, out1);
if(u2.num)
{
fputc(u2.num, out2);
fwrite(u2.address, u2.num, 1, out2);
}
}

BYTE FindFILE(BYTE *word, FILE *in)
{
BYTE buf[100];
BYTE num;

num = 0;
while(!feof(in))
{
Getline(in, buf);
if(strcmp(buf, word)==0)
return num;
num++;
}
return 0xFF;
}

void Getline(FILE *in, BYTE *word)
{
BYTE i;
BYTE ch;

i = 0;
while(!feof(in))
{
ch = fgetc(in);
if(feof(in))
break;
if(ch==0x0a)
break;
word[i++] = ch;
}
word[i] = 0;
}
BYTE GetBS(FILE *in)
{
BYTE ch;
BYTE bs= 0XFF;

if(feof(in))
return 0xFF;

bs = fgetc(in);

if(feof(in))
return 0xFF;

if(bs!='A'&&bs!='C')
{
printf("ERROR!!!!");
getch();
}
while(ch!=':')
ch = fgetc(in);

return bs;
}

BYTE gbfalg;

void WriToFILE(FILE *in0, FILE *out0)
{
FENGXIAN fengxianModo;
DWORD address;

while(!feof(in0))
{
gbfalg = 0;
memset(fengxianModo.xishuname, 0, 100);
memset(fengxianModo.qujian, 0, 2);
////memset(fengxianModo, 0, sizeof(struct FengXian0));

Getword_fengxian(in0, fengxianModo.xishuname);
if(fengxianModo.xishuname[0]==0)
break;
address = ftell(in0);
fengxianModo.qujian[0] = GetNum(in0);
if(gbfalg)
{
fengxianModo.qujian[1] = GetNum(in0);
fengxianModo.baoxiantype = 1;
}
else
fengxianModo.baoxiantype = 0;//固定值
fseek(in0, address, SEEK_SET);
fengxianModo.upOrlow = UpORLow(in0);
fwrite(&fengxianModo, sizeof(struct FengXian0), 1, out0);
}
}

//"上调"==1,"优惠"==0
BYTE UpORLow(FILE *in)
{
BYTE i=0;
BYTE ch;
BYTE tmp[100];
BYTE Up_Low[2][10] = {
"上调","优惠"
};

ch = 0;
while(ch!=0x0a)
{
ch = fgetc(in);
if(ch==0x0a||feof(in))
{
if(feof(in))
return 0xFF;
break;
}
tmp[i++] = ch;
}
tmp[i] = 0;

if(NULL!=(strstr(tmp, Up_Low[0])))
return 1;
else if(NULL!=(strstr(tmp, Up_Low[1])))
return 0;
return 2;
}

void Getword_fengxian(FILE *in, BYTE *buf)
{
BYTE ch;
BYTE i;
DWORD address;

i = 0;
while(!feof(in))
{
ch = fgetc(in);
if(feof(in))
break;
if(ch==0x28)
address = ftell(in)-1;
if(ch==0x20)
continue;
buf[i++] = ch;
if(ch==0x29)
break;
}
buf[i] = 0;
fseek(in, address, SEEK_SET);
}

BYTE GetNum(FILE *in)
{
BYTE i=0;
BYTE ch=0;
BYTE tmp[10];

if(feof(in))
return 0xFF;
while(!feof(in))
{
ch = fgetc(in);
while(isdigit(ch))
{
tmp[i++] = ch;
ch = fgetc(in);
}
if(ch=='%')
break;
}
ch = fgetc(in);
if(ch==0x29)// ')'
gbfalg = 0;
else if(ch == '-')
gbfalg = 1;
else
{
printf("!!!!!ERROR");
getch();
}
tmp[i] = 0;
return (BYTE)(atoi(tmp));
}这个程序是关于数据结构的我不明白是怎么回事 谁知道告诉我一下啊

搜索更多相关主题的帖子: word 
2007-01-09 16:50
快速回复:大家都来看看啊帮个忙
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024890 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved