c语言程序设计家电仓库管理系统 求大神帮助

2024-11-18 05:29:41
推荐回答(4个)
回答1:

#include
#include
#include
#define SIZE 2//SIZE为仓库电器种类
struct goods
{
char name[10];
char brand[10];
char style[10];
int num;
float money;
}stu[SIZE];//库存结构
struct date
{
int year;
int month;
int day;
};//日期结构
struct entrance
{
char name[10];
char brand[10];
char style[10];
int num;
float money;
struct date time;
char stuf[10];
}stu_2[SIZE];//入库结构
struct exit
{
char name[10];
char brand[10];
char style[10];
int num;
struct date time;
char stuf[10];
}stu_3[SIZE];//出库结构
void main()
{
void save_1();
void save_2();
void save_3();
void change_1();
void change_2();
void found_1();
void found_2();
int i;
printf("please input the information:\n");
for(i=0;i {
scanf("%s%s%s%d%d",stu[i].name,stu[i].brand,stu[i].style,&stu[i].num,&stu[i].money);
} //输入库存
save_1(); //利用函数将库存保存
FILE *fp;
fp=fopen("stu_list.txt","rb");
for(i=0;i {
fread(&stu[i],sizeof(struct goods),1,fp);
printf("%s %s %s %d %d",stu[i].name,stu[i].brand,stu[i].style,stu[i].num,stu[i].money);
printf("\n");
} //读出信息
fclose(fp);
printf("请输入物资入库信息:\n");//输入入库信息
for(i=0;i scanf("%s%s%s%d%f%d%d%d%s",stu_2[i].name,stu_2[i].brand,stu_2[i].style,&stu_2[i].num,&stu_2[i].money,&stu_2[i].time.year,&stu_2[i].time.month,&stu_2[i].time.day,stu_2[i].stuf);
save_2(); //创建入库文件
change_1();
printf("请输入出库信息\n");
scanf("%s%s%s%d%d%d%d%s",stu_3[i].name,stu_3[i].brand,stu_3[i].style,&stu_3[i].num,&stu_3[i].time.year,&stu_3[i].time.month,&stu_3[i].time.day,stu_3[i].stuf);
for(i=0;i {
if(stu_3[i].num>stu[i].num)
{
printf("the error number!please input again!\n");
break;
}
else
{
save_3();
change_2();
}
}
found_1();
found_2();
}
void save_1()
{
FILE *fp;
int i;
if((fp=fopen("stu_list.txt","wb"))==NULL)
{
printf("connot open the file\n");
return;
}
for(i=0;i {
if(fwrite(&stu[i],sizeof(struct goods),1,fp)!=1)
printf("file write error\n");
}
fclose(fp);
}
void save_2()
{
FILE *fp;
int i;
if((fp=fopen("stu_list_2.txt","wb"))==NULL)
{
printf("connot open the file\n");
return;
}
for(i=0;i {
if(fwrite(&stu_2[i],sizeof(struct entrance),1,fp)!=1)
printf("file write error\n");
}
fclose(fp);
}
void change_1()
{
int i;
for(i=0;i {
if(strcmp(stu[i].name,stu_2[i].name)==0&&strcmp(stu[i].brand,stu_2[i].brand)==0&&strcmp(stu[i].style,stu_2[i].style)==0)
{
stu[i].num=stu[i].num+stu_2[i].num;
}
}
save_1();
}
void save_3()
{
FILE *fp;
int i;
if((fp=fopen("stu_list_3.txt","wb"))==NULL)
{
printf("connot open the file\n");
return;
}
for(i=0;i {
if(fwrite(&stu_3[i],sizeof(struct exit),1,fp)!=1)
printf("file write error\n");
}
fclose(fp);
}
void change_2()
{
int i;
for(i=0;i {
if(strcmp(stu[i].name,stu_3[i].name)==0&&strcmp(stu[i].brand,stu_3[i].brand)==0&&strcmp(stu[i].style,stu_3[i].style)==0)
{
stu[i].num=stu[i].num-stu_3[i].num;
}
}
save_1();
}
void found_1()
{
FILE *fp;
int i;
int sum=0;
char name[10];
char brand[10];
printf("please input the name and brand:\n");//4.1 4.2 5.1
scanf("%s%s",name,brand);

if((fp=fopen("stu.list.txt","rb"))==NULL)
{
printf("connot open the file!\n");
return;
}
for(i=0;i {
if(fread(&stu[i],sizeof(struct goods),1,fp)!=1)
{
if(strcmp(name[10],stu[i].name[10])==0)
{
printf("the information of the good:\n");
printf("%s %s %s %d %d",stu[i].name,stu[i].brand,stu[i].style,stu[i].num,stu[i].money);
sum=sum+stu[i].num;
}
if(strcmp(brand[10],stu[i].brand[10])==0)
{
printf("the information of the good:\n");
printf("%s %s %s %d %d",stu[i].name,stu[i].brand,stu[i].style,stu[i].num,stu[i].money);

}
}
}
printf("the number of this %s is %d.\n",name[10],sum);
}
void found_2()
{
FILE *fp;
int i;
int j;
int sum=0;
int year_1,year_2,month_1,month_2,day_1;
char name_1[10],name_2[10],style_1[10];
if((fp=fopen("stu_list_2.txt","rb"))==NULL)
{
printf("connot open the file!\n");
return;
}
if((fp=fopen("stu_list_3.txt","rb"))==NULL)
{
printf("connot open the file!\n");
return;
}
printf("please input year_1,month_1,day_1,then find the exit and entrance:\n");
scanf("%d%d%d",&year_1,&month_1,&day_1);
printf("please input the name and style,then find the good's entrance and exit");
scanf("%s%s",name_1,style_1);
printf("please input the name of the good,then output the number or its entrance:\n");
scanf("%s",name_2);
printf("please input year_2 and month_2,then output the number of exit in this month:\n");
scanf("%d%d",&year_2,&month_2);
printf("please input the red number,then output all the informations of the goods:\n");
scanf("%d",&j);
for(i=0;i {
if((fread(&stu_2[i],sizeof(struct entrance),1,fp)!=1)&&(fread(&stu_3[i],sizeof(struct exit),1,fp)!=1))//读出入库和出库信息
{
if((stu_2[i].time.year==year_1)&&(stu_2[i].time.month==month_1)&&(stu_2[i].time.day==day_1))//入库信息4.3
{
printf("%s%s%s%d%f%d%d%d%s",stu_2[i].name,stu_2[i].brand,stu_2[i].style,stu_2[i].num,stu_2[i].money,stu_2[i].time.year,stu_2[i].time.month,stu_2[i].time.day,stu_2[i].stuf);
}
if((stu_3[i].time.year==year_1)&&(stu_3[i].time.month==month_1)&&(stu_3[i].time.day==day_1))//出库信息4.3
{
printf("%s%s%s%d%d%d%d%s",stu_3[i].name,stu_3[i].brand,stu_3[i].style,stu_3[i].num,stu_3[i].time.year,stu_3[i].time.month,stu_3[i].time.day,stu_3[i].stuf);
}
}
}
for(i=0;i {
if((fread(&stu_2[i],sizeof(struct entrance),1,fp)!=1)&&(fread(&stu_3[i],sizeof(struct exit),1,fp)!=1))//读出入库和出库信息
{
if((strcmp(stu_2[i].name,name_1))==0&&(strcmp(stu_2[i].style,style_1))==0)
{
printf("%s%s%s%d%f%d%d%d%s",stu_2[i].name,stu_2[i].brand,stu_2[i].style,stu_2[i].num,stu_2[i].money,stu_2[i].time.year,stu_2[i].time.month,stu_2[i].time.day,stu_2[i].stuf);
}
if((strcmp(stu_3[i].name,name_1))==0&&(strcmp(stu_3[i].style,style_1))==0)
{
printf("%s%s%s%d%d%d%d%s",stu_3[i].name,stu_3[i].brand,stu_3[i].style,stu_3[i].num,stu_3[i].time.year,stu_3[i].time.month,stu_3[i].time.day,stu_3[i].stuf);
}
}
}
for(i=0;i {
if((fread(&stu_3[i],sizeof(struct exit),1,fp)!=1))
if(stu_3[i].time.year==year_2&&stu_3[i].time.month==month_2)
{
sum=sum+stu_3[i].num;
}
}
printf("the time of exit is %d.\n",sum);
for(i=0;i {
if((fread(&stu[i],sizeof(struct goods),1,fp)!=1))
{
if(stu[i].num {
printf("th information of the good are:\n");
printf("%s%s%s%d%f",stu[i].name,stu[i].brand,stu[i].style,stu[i].num,stu[i].money);
}
}
}
}

回答2:

管理系统用C设计,有点精卫填海的意思啊。

回答3:

加油!自己动手,丰衣足食!

回答4:

??