当前位置: 代码迷 >> C语言 >> 这个程序有个函数的问题
  详细解决方案

这个程序有个函数的问题

热度:134   发布时间:2007-08-02 19:49:46.0
我是说K在存储里面没有给初值,你那个比较有意义吗?
----------------解决方案--------------------------------------------------------
恩,K就是项目,是用来跟踪项目的,第K项,,

----------------解决方案--------------------------------------------------------

你就帮我改改,,只要满足上面的功能就行,
今天编这个程序都弄糊涂了, 谢谢了


----------------解决方案--------------------------------------------------------
行,只怕没那么快,你等等,今天就有答复
----------------解决方案--------------------------------------------------------
恩,,谢谢了
----------------解决方案--------------------------------------------------------

你这个程序要想完美,要改的还真不少,现在是没有错误,也能存储,但明显不能达到要求,关键是,
你还得有个修改的函数,不然输入错误,改都改不了,这样吧,我给你改完美些,可能今天没时间了,
一般9点就得回去


----------------解决方案--------------------------------------------------------

void FindMessage()
{
int i,j;
FILE *datafp;
if((datafp=fopen("D:\\fujian.txt","rb"))==NULL)
{
printf("cannot open data file!\n");
return;
}
ClearStructArr(a);
ClearGameItemTable();
for(i=0,j=0;i<50;i++)
{
fscanf(datafp,"%d %d",&GameItemTable[i][0],&GameItemTable[i][1]);
for(int k=0;k<GameItemTable[i][1];k++)
{
a[j].Item=GameItemTable[i][0];
if(fscanf(datafp,"%s %s %ld %d",a[j].name,a[j].Department,&a[j].num,&a[j].Position)==EOF)break;
j++;
}
if(feof(datafp))break;
}
fclose(datafp);
int choice;
printf("How to Find? Make a choice!\n");
printf("1.You can find by your SchoolNumber!\n");
printf("2.You can find by GameItem!\n");
printf("3.You can find by GameItem and GamePosition!\n");
printf("else,You Will exit the Finding...");
scanf("%d",&choice);
if(choice==1)
{
long schoolnum;
int FindIt=1;
printf("Please input the SchoolNumber you want to Find:\n");
scanf("%ld",&schoolnum);
for(i=0;i<50;i++)
{
if(a[i].num==schoolnum)
{
printf("You have Successly Find!\n");
printf("%s,%s,%ld,%d,%d\n",a[i].name,a[i].Department,a[i].num,a[i].Item,a[i].Position);
FindIt=0;
}

}
if(FindIt)
{
printf("Sorry! there is not record like that...\n");
}
}
else if(choice==2)
{
int gameitem;
int FindIt=1;
printf("Please input the GameItem you want to Find:\n");
scanf("%d",&gameitem);
for(i=0;i<50;i++)
{
if(a[i].Item==gameitem)
{
printf("%s,%s,%ld,%d,%d\n",a[i].name,a[i].Department,a[i].num,a[i].Item,a[i].Position);
FindIt=0;
}
}
if(FindIt)
{
printf("Sorry! there is not record like that...\n");
}
else
{
printf("You have Successly Find! Above is the record!\n");
}
}
else if(choice==3)
{
int gameitem1;
int gameposition;
int FindIt=1;
printf("Please input the GameItem and the GamePosition you want to Find:input like(a b)\n");
scanf("%d %d",&gameitem1,&gameposition);
for(i=0;i<50;i++)
{
if((a[i].Item==gameitem1)&&(a[i].Position==gameposition))
{
printf("%s,%s,%ld,%d,%d\n",a[i].name,a[i].Department,a[i].num,a[i].Item,a[i].Position);
FindIt=0;
}
}
if(FindIt)
{
printf("Sorry! there is not record like that...\n");
}
else
{
printf("You have Successly Find! Above is the record!\n");
}

}
else
{
getchar();
return;
}

}

把查找函数也改了下,应该能用,你如果用的TC就把在中间定义的都移上去就行了


----------------解决方案--------------------------------------------------------
  相关解决方案