当前位置:首页 » 编程语言 » c语言编商品管理系统
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言编商品管理系统

发布时间: 2022-10-06 15:49:28

c语言商品管理系统

假设某超市经营各种商品,每种商品包括以下信息:商品编号、商品名称、商品品牌、库存数量、售价、已售数量。系统的主要功能包括:1. 创建商品信息文件:根据提示输入若干商品的信息,并将信息保存至一个文件中。2. 商品进货管理:每次购入新商品,需按要求输入商品所含各项信息并存入商品信息文件中。如果已经存在该商品(以商品编号为准),则修改相应的库存数量信息,否则生成新的商品信息记录。3. 商品销售管理:每次有商品销售出去,则按要求输入商品编号和商品名称信息,并修改相应的商品信息文件。注意:商品销售时要检查库存数量的合法性(即销售出去的数量必须小于库存数量)。4. 按不同条件进行查询操作,输出满足条件的商品信息。(1) 输入商品名称,在商品信息文件中查找相应的商品信息并输出。(2) 输入商品品牌,在商品信息文件中查找该品牌的所有信息并输出。5. 按不同条件对商品信息进行统计工作。(1) 输入商品名称,在商品信息文件中统计该商品的销售总额。(2) 设置一个库存数量警戒值,输出库存数量小于该警戒值的所有库存商品的信息。(3) 输入商品品牌,在商品信息文件中统计其不同商品名称的库存量,并输出库存量最高的那个商品的信息。
满意请采纳。

② C语言做个小型商品销售管理系统

我这里有一个!
具体的,稍微改一下就可以了!

#include "stdio.h" /*I/O函数*/
#include "stdlib.h" /*其它说明*/
#include "string.h" /*字符串函数*/
#include "conio.h" /*屏幕操作函数*/
#include "mem.h" /*内存操作函数*/
#include "ctype.h" /*字符操作函数*/
#include "alloc.h" /*动态地址分配函数*/
struct score
{
int mingci;
char xuehao[8];
char mingzi[20];
float score[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;

void shuru()
{
if((fp=fopen("s_score.txt","ab+"))==NULL)
{
printf("cannot open this file.\n");
getch();exit(0);
}
for(i=0;i<=1000;i++)
{
printf("\nPlease shuru xuehao:");
gets(data.xuehao);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please shuru wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please shur huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];
fwrite(&data,sizeof(data),1,fp);
printf("another?y/n");
ch=getch();
if(ch=='n'||ch=='N')
break;
} fclose(fp);
}
void xianshi()
{
float s;int n;
if((fp=fopen("s_score.txt","rb+"))==NULL)
{
printf("Cannot reading this file.\n");
exit(0);
}
for(i=0;i<=1000;i++)
{
if((fread(&info[i],sizeof(info[i]),1,fp))!=1)
break;
}
printf("\nxuehao mingzi yuwen shuxue yingyu wuli huauxue zhongfen\n");
for(j=0,k=1;j<i;j++,k++)
{
info[j].mingci=k;
printf("%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n",info[j].xuehao,info[j].mingzi,info[j].score[0],info[j].score[1],info[j].score[2],info[j].score[3],info[j].score[4],
info[j].score[5]);
}
getch();
fclose(fp);
}

void xiugai()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("Cannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xiugai xuehao:");
scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("xuehao:%s\nmingzi:%s\n",data.xuehao,data.mingzi);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please input wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please input huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];

} fwrite(&data,sizeof(data),1,fp1);
}
fseek(fp,0L,0);
fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1)
{
fwrite(&data,sizeof(data),1,fp);
}

fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_score.txt","rb"))==NULL)
{
printf("\nCannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xuehao chakan:");
scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1)
{
j=atoi(data.xuehao);
if(i==j)
{
printf("xuehao:%s mingzi:%s\nyuwen:%f\n shuxue:%f\n yingyu:%f\n wuli:%f\n huaxue:%f\n ",data.xuehao,data.mingzi,data.score[0],data.score[1],data.score[2],data.score[3],data.score[4],data.score[5]);
}getch();
}
}
void shanchu()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("\nopen score.txt was failed!");
getch();
exit(0);
}
printf("\nPlease input ID which you want to del:");
scanf("%d",&i);getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{

printf("Anykey will delet it.\n");
getch();
continue;
}
fwrite(&data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove("s_score.txt");
rename("temp.txt","s_score.txt");
printf("Data delet was succesful!\n");
printf("Anykey will return to main.");
getch();
}
main()
{
while(1)
{
clrscr(); /*清屏幕*/
gotoxy(1,1); /*移动光标*/
textcolor(YELLOW); /*设置文本显示颜色为黄色*/
textbackground(BLUE); /*设置背景颜色为蓝色*/
window(1,1,99,99); /* 制作显示菜单的窗口,大小根据菜单条数设计*/
clrscr();
printf("*************welcome to use student manage******************\n");
printf("*************************menu********************************\n");
printf("* ========================================================= * \n");
printf("* 1>shuru 2>xiugai * \n");
printf("* 3>shanchu 4>chazhao * \n");
printf("* 5>xianshi 6>exit * \n");
printf("* * \n");
printf("* --------------------------------------------------------- * \n");
printf(" Please input which you want(1-6):");
ch=getch();
switch(ch)
{
case '1':shuru();break;
case '2':xiugai(); break;
case '3':shanchu(); break;
case '4':chazhao(); break;
case '5':xianshi(); break;
case '6':exit(0);
default: continue;
}
}
}

③ 用c语言实现超市商品管理系统,用指针实现商品的插入、删除操作。

可以用链表,大致就是,你创建一个结构体,结构体里有商品的一些信息,然后关键的是有个该结构体的指针,这个指针是指向下一个商品的结构体地址的,依次类推,直到最后一个商品的指针是指向null的,然后开始插入商品的思路:①创建新商品的信息②先让你要插入的结构体的指针指向要插入的那个位置后边的地址,③然后插入位置的前面的结构体指向要插入商品④如果是插在末尾,或者开头,你就注意是谁指向谁的问题。删除商品思路:直接修改要删除的商品之前的指针,绕过要删除的商品,指向下一个不擅长的商品就ok。

structbook
{
longbook_number;//记录书的编号
charbook_name[N];//储存书的名字
doublebook_price;//记录书的价格
charbook_author[N];//记录书的作者
charbook_state[N];//记录书的借还状态
intbook_num;//记录书的数量
charborrower_name[N];//记录借书人姓名
charborrower_sex[M];//记录借书人性别
longborrower_number;//记录借书人学号
structbook*book_next;//指向下一个结构体
};//以前写的图书管理系统作为链表元素的结构体,只要关注最后一个指针就好了

BOOK*DelBook(BOOK*book_head)/*此函数负责删除图书*//*思路为连续读取文件内容,找到要删除的文件内容的位置,写入一份新的文件,再替换掉旧文件*/
{
longnum;//记录书籍号
intflag=0;//控制开关
charch;//记录用户的选择
BOOK*p=book_head;
BOOK*pr=NULL;

printf(" 功能:删除一本图书的所有信息 ");
printf("输入你要删除的书籍号");
scanf("%ld",&num);
read_book_file(book_head);//将图书信息写入节点
while(num!=p->book_number&&p->book_next!=NULL)//查找节点并显示节点内容并且记录节点的地址
{
pr=p;
p=p->book_next;
}
if(book_head==NULL)/*数据不能正常获取*/
{
exit(0);
}
elseif(num=p->book_num)/*找到了对应的*/
{
PrintBook(p);
printf("你确定要删除么?");
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
{

while(!flag)
{
if(book_head==NULL)
{
printf("链表为空 ");
returnbook_head;
}
if(p==book_head)//如果是头节点要删除
{
book_head=p->book_next;
free(p);//释放删除节点
flag=1;
}
elseif(p->book_next==NULL)//如果是末节点
{
free(p);//释放删除的节点
p=pr;//改变p的指向
p->book_next==NULL;
flag=1;
}
else
{
pr->book_next=p->book_next;//删除中间节点
free(p);//释放删除的节点
flag=1;
}
/*节点删除结束*//*接下来将新的内容写入文件,之前那些内容被覆盖*/
save_book_file(book_head);//调用文件写入函数重新写入
//这样直接就实现了内容的覆盖,相当于删除文本内容
returnbook_head;//最后返回头节点
}
}
else/*未找到*/
{
fflush(stdin);
returnbook_head;
}
}
returnbook_head;
}

以前写的令一个管理系统的一部分,将就着看吧,插入商品和这个差不多

④ 用c语言制作商店商品管理系统

#include <stdio.h>
#include <conio.h>
#include <bios.h>
#include <dos.h>
#include <malloc.h>
#define NULL 0
#define LEN sizeof(struct mcd)
struct data /*声明一个日期的结构体类型*/
{
int year;
int month;
int day;
};
struct mcd /*声明有关商品信息的结构体类型*/
{
int code; /*编 号*/
char name[12]; /*品 名*/
long price; /*单 价*/
int num; /*数 量*/
char place[20]; /*产 地*/
struct data putdate; /*入库时间*/
struct data selldate; /*销售时间*/
struct mcd * next; /*运用指针处理链表*/
};
int n; /*记录链表有几条数据*/
struct mcd *head; /*声明链表头的指针*/

creat() /*输入商品信息的函数*/
{
struct mcd *p1,*p2;
n=0;
p1=p2=(struct mcd *)malloc(LEN); /*开辟一个新单元存放信息*/
head=p1;
loop: {
clrscr();
printf("商品录入系统\n");
printf("录入号:%d\n",n+1);
printf("编 码:");
scanf("%d",&p1->code);
printf("品 名:");
scanf("%s",&p1->name);
printf("单 价:");
scanf("%ld",&p1->price);
printf("数 量:");
scanf("%d",&p1->num);
printf("产 地:");
scanf("%s",&p1->place);
printf("入库时间:");
scanf("%d-%d-%d",&p1->putdate.year,&p1->putdate.month,&p1->putdate.day);
}
while(p1->num!=0)
{
n=n+1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct mcd *)malloc(LEN);
goto loop;
}
p2->next=NULL;
main();
}

print() /*输出数据列表的函数*/
{
int m=0;
struct mcd *p;
clrscr();
printf("编 号||品 名||单 价||数 量|| 产 地 ||入 库 时 间\n");
p=head;
if(head!=NULL)
do
{
printf("%-10d%-14s%-12ld%-10d%-22s%-4d-%-2d-%-2d\n",p->code,p->name,p->price,p->num,p->place,p->putdate.year,p->putdate.month,p->putdate.day);
p=p->next;
m=m+1;
if(m%23==0){gotoxy(10,25);printf("按任意键继续.");getch();}
}while(p!=NULL);
getch();
main();
}

sell()
{
int code,m=3,ch;
long sum=0;
struct mcd *p1;
struct date today;
getdate(&today);
clrscr();
printf("商品销售系统\n");
printf("编 号||||品 名|||| 产 地 ||||单 价(元)||||出 售 时 间\n");
loop:
do{
gotoxy(23,25);
printf("按任意键继续,F2结帐,ESC键退出");
ch=bioskey(0);
}while(0);
switch(ch)
{
case 15360:{
if(sum==0)
{
gotoxy(1,m);printf("还没有购买商品!");
getch();
sell();
break;
}
else {
gotoxy(1,m);
printf("------------------------------------------------------------------------------");
gotoxy(47,m+1);
printf("总价: %-12ld元",sum);
getch();
main();
break;
}
}
case 283:{main();break;}
default:
{
gotoxy(23,25);
printf("请输入商品编码,会显示商品信息");
gotoxy(1,m);
scanf("%d",&code);
if(head==NULL)
{
printf("你还没有进货.");
getch();
main();
break;
}
p1=head;
while(code!=p1->code&&p1->next!=NULL)
{p1=p1->next;}
if(code==p1->code)
{
gotoxy(13,m);
printf("%-16s%-24s%-16ld%4d-%2d-%2d",p1->name,p1->place,p1->price,today.da_year,today.da_mon,today.da_day);
m=m+1;
p1->num=p1->num-1;
sum=sum+p1->price;
}
}
goto loop;
}
}

go()
{
int ch;
clrscr();
printf("请问你要进行什么操作?\n1,插入;2,删除;3,什么也不做;\n");
loop:
do{
ch=bioskey(0);
}while(0);
switch(ch)
{
case 561:insert();break;
case 818:del();break;
case 1075:main();break;
case 283:break;
default:{gotoxy(1,3);printf("请按数字键选择!");goto loop;}
}
getch();
main();
}

insert()
{
struct mcd *p0,*p1,*p2;
p0=p1=p2=(struct mcd*)malloc(LEN);
p1=head;
clrscr();
printf("请输入要插入的商品的信息:\n");
printf("编 码:");
scanf("%d",&p0->code);
printf("品 名:");
scanf("%s",&p0->name);
printf("单 价:");
scanf("%ld",&p0->price);
printf("数 量:");
scanf("%d",&p0->num);
printf("产 地:");
scanf("%s",&p0->place);
printf("入库时间:");
scanf("%d-%d-%d",&p0->putdate.year,&p0->putdate.month,&p0->putdate.day);
if(head==NULL)
{
head=p0;
p0->next=NULL;
}
else
{
while((p0->code>p1->code)&&(p1->next!=NULL))
{
p2=p1;
p1=p1->next;
}
if(p0->code<=p1->code)
{
if(head==p1)head=p0;
else p2->next=p0;
p0->next=p1;
}
else
{
p1->next=p0;p0->next=NULL;
}
}
n=n+1;
print();
}

del()
{
int code;
struct mcd *p1,*p2;
clrscr();
printf("请输入要删除商品的编号:");
scanf("%d",&code);
if(head==NULL)
{
printf("你还没有进货.");
getch();
main();
}
p1=head;
while(code!=p1->code&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(code==p1->code)
{
if(code==head)head=p1->next;
else p2->next=p1->next;
n=n-1;
print();
}
else
{
printf("找不到这条商品信息.");
getch();
print();
}
}

main()
{
do{
clrscr();
printf(" . : : \n");
printf(" '. :'''''''': : : :'''':'''':\n");
printf(" '. : : :'''''' :'''''' : : :\n");
printf(" ................ : : :', :', ''''':''''': : :\n");
printf(" '. .' : : : ', : ', : :....:....:\n");
printf(" '. .' : : ,' ,' : : : :\n");
printf(" '.' : : ', : : : :\n");
printf(".........:........... :........: : ', : :....:....:\n");
printf(" ............... :''''''''''''''': '''':'''' : \n");
printf(" : , , : :'''''': :'''''': ,' : : \n");
printf(" : , , : : : : : :''''''''': : ,' : \n");
printf(" : , , : : : : : : : : ,' ....:.... \n");
printf(" :, :''''''': : : : : : : : :,' : \n");
printf(" : : : : : : : : :'''''''''' ,' : \n");
printf(" : : : : : : : : :.......... ,' : \n");
printf(" : :.......: : : : : : : : ' : \n");
printf(" : : : : : : : : ......:.....\n");
printf(" : ..: :......: :......: :.........: \n");
gotoxy(60,19);
printf("赵飞宇制造 V1.0");
gotoxy(10,21);
printf("1,销售系统;2,进货系统;3,查看列表;4,插入删除;5,销售盈亏;6,帮助文档");
gotoxy(32,24);
printf("按ESC键退出");
key();
}while(0);
}

key()
{
int ch;
loop:
do{
ch=bioskey(0);
}while(0);
switch(ch)
{
case 561:sell();break;
case 818:creat();break;
case 1075:print();break;
case 1332:go();break;
case 283:break;
default:
{
gotoxy(30,22);
printf("请按数字键选择!");
goto loop;
}
}

}

⑤ 用C语言编写一简单的商品销售管理系统

第一个功能商品入库其实就是输入数据
,不要想得太复杂,直接用scanf输入就可以了
第二个商品销售
就是改一下商品的数量
查询用折半查找顺序查找都可以
查到之后printf
排序可以用选择法但愿能帮到你

⑥ c语言商品系统管理代码框架

#include <stdio.h> #include <malloc.h> #include <string.h> typedef struct { char num[10]; char name[20]; float price; int amount; }Proct; typedef struct node { Proct p; struct node *pre; struct node *next; }node,*linklist; linklist head,last; void setData(linklist p) { printf("产品编号:"); scanf("%s",&p->p.num); printf("产品名称:"); scanf("%s",&p->p.name); printf("产品单价:"); scanf("%f",&p->p.price); printf("产品数量:"); scanf("%d",&p->p.amount); } void Insert(linklist p) { setData(p); p->next=last; last->pre->next=p; p->pre=last->pre; last->pre=p; } void Add() { char ch; do { linklist p=(linklist)malloc(sizeof(node)); system("cls"); Insert(p); printf("是否继续?"); scanf(" %c",&ch); }while(ch=='y'||ch=='Y'); } linklist Qur() { char num[10]; linklist p=head->next; printf("输入产品编号:"); scanf("%s",num); while(p!=last) { if(strcmp(num,p->p.num)==0) break; p=p->next; } if(p==last) {printf("未找到\n");system("pause");} return p; } void Del() { linklist p=Qur(); if(p==last) return; p->pre->next=p->next; p->next->pre=p->pre; free(p); printf("删除成功\n"); system("pause"); } void Modify() { linklist p=Qur(); if(p==last) return ; setData(p); } void printTitle() { printf("编号\t名称\t单价\t数量\n"); } void show(linklist p) { printf("%s\t%s\t%.2f\t%d\n",p->p.num,p->p.name,p->p.price,p->p.amount); } void Tongji() { linklist p=head->next; int i=0; printTitle(); while(p!=last) { show(p); p=p->next; i++; } printf("共%d项商品\n",i); system("pause"); } void Sort() { linklist p,q; for (p=head->next;p!=last;p=p->next) { for (q=p->next;q!=last;q=q->next) { if(strcmp(p->p.num,q->p.num)<0) { Proct temp=p->p; p->p=q->p; q->p=temp; } } } printf("完成\n"); system("pause"); } void Save() { linklist p=head->next; FILE *fp=fopen("d:\\record.txt","w"); if(fp==NULL) { printf("保存失败\n"); return; } fprintf(fp,"编号\t名称\t单价\t数量\n"); while(p!=last) { fprintf(fp,"%s\t%s\t%.2f\t%d\n",p->p.num,p->p.name,p->p.price,p->p.amount); p=p->next; } fclose(fp); printf("完成\n"); system("pause"); } void Disp() { linklist p=head->next; printTitle(); while(p!=last) { show(p); p=p->next; } system("pause"); } void Wrong() { printf("输入错误!\n"); system("pause"); } void menu(void) { system("cls"); printf("********商品销售管理系统*******\n"); printf("* *\n"); printf("* 1:添加 *\n"); printf("* 2:删除 *\n"); printf("* 3:查询 *\n"); printf("* 4:修改 *\n"); printf("* 5:插入 *\n"); printf("* 6:统计 *\n"); printf("* 7:降序排列 *\n"); printf("* 8:存储 *\n"); printf("* 9:显示数据 *\n"); printf("* 0:退出 *\n"); printf("* *\n"); printf("*******************************\n"); } int select() { int choose; scanf("%d",&choose); switch(choose) { case 1:Add();break; case 2:Del();break; case 3: { linklist p=Qur(); if(p!=last) {show(p);system("pause");}break; } case 4:Modify();break; case 5: { linklist p=(linklist)malloc(sizeof(node)); Insert(p);break; } case 6:Tongji();break; case 7:Sort();break; case 8:Save();break; case 9:Disp();break; case 0:break; default:Wrong();break; } return choose; } void destroy() { linklist p=head->next; while(p!=last) { head->next=p->next; free(p); p=head->next; } free(head); free(last); } int main(void) { head=(linklist)malloc(sizeof(node)); last=(linklist)malloc(sizeof(node)); head->next=last; last->next=NULL; last->pre=head; head->pre=NULL; do { menu(); } while (select()!=0); destroy(); return 0; }

⑦ c语言设计商品信息管理系统

如果你不是为了学习用途,直接用蓝点产品管理系统好了,这些需求基本直接就实现了的。

⑧ c语言 商品管理系统

#include"stdio.h"
#include <conio.h>
#include <stdlib.h>
//#include"FILE.h"
typedef struct shangpin
{
char name[20];
int biaohao;
int shuliang;
double jiage;
}Node;
typedef struct list
{
Node data;
struct list *next;
}List ,*Slist;
void charu(Slist &s,Node x);

int caidan()
{
int i;
while(1)
{
system("cls");
printf("\n\t\t\t 商店销售管理系统\n\n");
printf("\t\t **********************************************\n\n");
printf("\t\t 1--添加商品 2--出售商品\n\n");
printf("\t\t 3--删除商品 4--显示商品\n\n");
printf("\t\t 5--查找商品 0--退出系统\n\n");
printf("\t\t **********************************************\n\n");
printf("请选择(0-5): ");
scanf("%d",&i);
if(i<6&&i>=0)break;
}
return i;
}

void chushihua(Slist &s)
{
Slist head=new List;
head->next=NULL;
s=head;
}
void tianjia(Slist &s)
{
Node x;
Slist r,p,q;
int i=0;
r=new List;
r->next=NULL;
q=p=s->next;
while(q)
{
i++;
q=q->next;
}
printf("请输入商品名称、数量以及价格: ");
scanf("%s%d%lf",x.name,&x.shuliang,&x.jiage);
x.biaohao=i+1;
r->data=x;
s->next=r;
r->next=p;
}
void chu(Slist &s)
{
FILE *cp;//定义文件指针
int i=0;
Node x;

if((cp=fopen("shangpin.txt","a+"))==NULL)//打开文件
{printf("文件打开失败!");return ;}
fseek(cp,0L,SEEK_SET);//将文件指针移动到文件开头
while(!feof(cp))
{
fscanf(cp,"%s%d%lf",x.name,&x.shuliang,&x.jiage);//读取文件的内容
x.biaohao=++i;
charu(s,x);//把读到的数据插入到链表上
}
fclose(cp);//关闭文件
}
void charu(Slist &s,Node x)
{
Slist r,p=s->next;
r=new List;
r->next=NULL;
r->data=x;
s->next=r;
r->next=p;
}
void xieru(Slist s)
{
FILE *cp;//同上
Slist p=s->next;
if((cp=fopen("shangpin.txt","w+"))==NULL)
{printf("文件打开失败!");return ;}//同上
while(p)
{
fprintf(cp,"%s %d %.2lf ",p->data.name,p->data.shuliang,p->data.jiage);//写入文件中,并且以空格隔开
p=p->next;
}
fclose(cp);//关闭文件
}
Slist chazhao(Slist s,int m)
{
Slist p=s->next;
if(p==0)return 0;
if(p->next==0)return p;
if(p->data.biaohao==m)return p;
while(p->next)
{
if(p->next->data.biaohao==m)return p;
p=p->next;
}
return 0;
}
void xianshi(Slist s)
{
Slist p;
p=s->next;
printf("%10s%20s%10s%10s\n","商品编号","商品名称","商品数量","商品价格");
while(p)
{
printf("%10d%20s%10d%10.2f\n",p->data.biaohao,p->data.name,p->data.shuliang,p->data.jiage);
p=p->next;
}

}
void shanchu(Slist &s)
{

}
void chushou(Slist &s)
{

}
void main()
{
int num;
Slist s;
chushihua(s);
chu(s);
num=caidan();
while(1)
{

switch(num)
{
case 0:exit(0);break;
case 1:tianjia(s);break;
case 2:chushou(s);break;
case 3:shanchu(s);break;
case 4:xianshi(s);break;
case 5:chazhao(s,1);break;
}
printf("按任意键继续!");
getch();
num=caidan();
}
xieru(s);
}

//有些函数我在没写啊,你自己写写吧,文件的读取和写入,还有链表的创建我都给你写好了,也就是上面的1,4我都写好了,
//包括了文件,剩下的2,3,5,你自己试试,并且我也给你写了一个查找函数,你看看能用不!

⑨ C语言 商品管理系统

好难!

⑩ 商品库存管理系统的c语言源代码

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

struct BOOK
{
int id,usr[10],total,store,days[10];
char name[31],author[21];
}books[100];
/*上面是结构体的定义,用于存放书籍及借书的信息。*/

void page_title(char *menu_item)
{
clrscr();
printf(">>> 图 书 管 理 系 统 <<<\n\n- %s -\n\n",menu_item);
}
/*上面是打印页眉的函数,同时通过参数menu_item,可以显示当前的状态。*/

void return_confirm(void)
{
printf("\n按任意键返回……\n");
getch();
}
/*上面是返回前请求确认的函数,以便在返回前观察结果*/

int search_book(void)
{
int n,i;
printf("请输入图书序号:");
scanf("%d",&i);
for(n=0;n<100;n++)
{
if(books[n].id==i)
{
printf("书名:%s\n",books[n].name);
printf("作者:%s\n",books[n].author);
printf("存数:%d of ",books[n].store);
printf("%d\n",books[n].total);
return n;
}
}
printf("\n输入错误或无效图书序号.\n");
return -1;
}
/*上面的函数是在数组中找到图书号匹配的记录,显示其信息并返
回数组下标,如果找不到相应记录则提示错误并返回-1。*/

void book_out(void)
{
int n,s,l,d;
page_title("借阅图书");
if((n=search_book())!=-1&&books[n].store>0)
{
printf("请输入借书证序号:");
scanf("%d",&s);
printf("请输入可借天数:");
scanf("%d",&d);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==0)
{
books[n].usr[l]=s;
books[n].days[l]=d;
break;
}
}
books[n].store--;
}
if(n!=-1&&books[n].store==0) printf("此书已经全部借出.\n");
return_confirm();
}
/*上面是借书的函数,首先调用找书函数*/

void book_in(void)
{
int n,s,l;
page_title("归还图书");
if((n=search_book())!=-1&&books[n].store<books[n].total)
{
printf("借阅者图书证列表:\n");
for(l=0;l<10;l++)
if (books[n].usr[l]!=0)
printf("[%d] - %d天\n",books[n].usr[l],books[n].days[l]);
printf("请输入借书证序号:");
scanf("%d",&s);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==s)
{
books[n].usr[l]=0;
books[n].days[l]=0;
break;
}
}
books[n].store++;
}
if(n!=-1&&books[n].store==books[n].total)
printf("全部入藏.\n");
return_confirm();
}

void book_add(void)
{
int n;
page_title("注册新书");
for(n=0;n<100;n++)
if(books[n].id==0) break;
printf("序号:");
scanf("%d",&books[n].id);