欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    c语言图书销售系统(源代码).doc

    • 资源ID:33545782       资源大小:97.50KB        全文页数:33页
    • 资源格式: DOC        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    c语言图书销售系统(源代码).doc

    #include <stdio.h>#include <string.h>#include <malloc.h>#include <stdlib.h>#include <time.h>#include <conio.h>#define LEN sizeof(struct book)#define VLEN sizeof(struct vip)#define SLEN sizeof(struct sales)struct vip *vhead=NULL;struct vip *v1,*v2;struct sales *shead=NULL;struct sales *s1,*s2;int V,S;/*结构体定义*/struct bookchar bnum 12;/*书号*/char bname 41;/*书名*/char author 20;/*作者*/float price;/*书价*/int acount;/*书存在本数*/struct book *next;struct salesfloat count;struct sales *snext;struct vipchar vnum12;char vname41;int level;float persum;float discount;struct vip *vnext;/*函数声明*/void loadbook();/*自动读入书库信息*/void welcome();/*欢迎界面显示*/void inputbook();/*增加书本信息*/void loadvip();void loadsales(); /*自动录入销售信息*/void daysales(); /*日销售额*/void monthsales(); /*月销售额*/void yearsales(); /*年销售额*/void search();/*查询书数量*/void search_by_bnum();/*通过书号查询*/void search_by_bname();/*通过书名查询*/void search_by_author();/*通过作者查询*/void buy();/*购买书籍*/void list();/*列出书库信息*/void listvip();void listsales(); /*列出销售信息*/void delet();/*删除书目*/void delet_by_bnum();/*通过书号删除*/void delet_by_bname();/*通过书名删除*/void delet_by_author();/*通过作者删除*/void save();/*保存记录*/void redef();/*修改密码*/void bover();/*显示已售完的书*/void buy_by_huiyuan(); /*会员买书*/void buy_by_feihuiyuan(); /*非会员买书*/void exit0();/*退出*/int menu();/*主菜单*/void print2();/*显示查询菜单*/void printdelete();/*显示删除菜单*/struct book *head=NULL,*head2=NULL;/*head和head2分别用于书库的头指针和已购书的头指针*/struct book *p1,*p2,*p3,*p4,*p5,*p6;/*p1、p2、p3用于操作书库图书,p4、p5、p6用于操作已购书*/int save_flag=0;/*图书信息变动标志*/int buy_flag=0;/*买书时,是否调用过查询功能标志*/int shan_flag=0;/*删书时,是否调用过显示已售完书功能标志*/int T=0;/*记录导入的书本数*/char mima11="123456"/*初始密码*/void bookmanage();void salesmanage(); /*销售统计*/int main() /*主函数*/welcome();/*欢迎界面显示*/loadbook();loadsales();loadvip();/*自动导入书库信息*/while(1)switch(menu()case 1:system("cls");bookmanage();break;case 2:system("cls");buy();break;case 3:system("cls");listvip();break;case 4:system("cls");salesmanage();break;case 5:system("cls");break;case 0:system("cls");exit0();break;default:printf("n选择错误,请按主菜单提示输入您的正确选择(08)n");printf("按任意键返回继续:");rewind(stdin);/*清空缓冲区*/getch();return 0;/*菜单*/int menu()int choice;system("cls"); /*系统清屏*/printf("n *主菜单*nn");printf("1.图书管理nn"); printf("2.销售管理nn");printf("3.会员管理nn");printf("4.销售额统计nn");printf("5.说明nn");printf("0.退出nnn");printf("请输入您的选择(08):");rewind(stdin);/*清空缓冲区*/scanf("%d",&choice);return choice;/*返回用户的选择*/void bookmanage() system("cls"); int choice1; do printf(" "); /*显示菜单*/printf(" *图书管理* "); printf(" ");printf(" ");printf(" 功能选项: n");printf(" 1 : 图书信息录入 n");printf(" 2 : 图书信息浏览 n");printf(" 3 : 图书信息查询 n");printf(" 4 : 图书信息删除 n");printf(" 5 : 图书信息保存 n");printf(" 0 : 返回主界面 n");printf(" ");printf("t请选择操作:"); scanf("%d", &choice1); switch (choice1) /*菜单选择*/ case 1 : system("cls");inputbook();break; case 2 : system("cls");list(); break ; case 3 :system("cls");search(); break ; case 4 : system("cls");delet(); break ; case 5 : system("cls");save(); break ; case 0 :system("cls");break; while (choice1!=0); printf("n");void welcome() /*欢迎界面显示*/ system("cls");printf("nntt*欢迎使用图书销售管理系统*nn");void loadbook() /*开始导入书库信息*/FILE *fp;struct book *p7;if(fp=fopen("0.txt","r")=NULL) /*打开文件*/printf("nn文件打开失败或文件不存在n");printf("nn按回车键继续:");getchar();return;head=p3=p1=(struct book*)malloc(LEN); /*开辟一个新单元*/p1->next=NULL;p7=(struct book*)malloc(LEN); /*作为一个临时存储空间,避免读取文件最后的回车符*/fscanf(fp,"%s %s %s %f %d",&p7->bnum,&p7->bname,&p7->author,&p7->price,&p7->acount);while(!feof(fp)T+;*p1=*p7; /*文件没结束就将p7中的信息给p1*/p2=(struct book*)malloc(LEN); /*继续开辟一个新单元,直到文件读完*/p1->next=p2;p3=p1;p1=p2;p1->next=NULL;fscanf(fp,"%s%s%s%f%d",&p7->bnum,&p7->bname,&p7->author,&p7->price,&p7->acount);free(p2); /*释放多申请的一个单元*/p3->next=NULL;printf("nnttt%d项图书信息已经由系统自动载入.nnttt",T);rewind(stdin);/*清空缓冲区*/if(fclose(fp)printf("文件关闭失败!n");exit(0);void salesmanage() system("cls"); int choice4; do printf(" "); /*显示菜单*/printf(" *销售统计* "); printf(" ");printf(" ");printf(" 功能选项: n");printf(" 1 : 日销售额 n");printf(" 2 : 月销售额 n");printf(" 3 : 年销售额 n");printf(" 0 : 返回主界面 n");printf(" ");printf("t请选择操作:"); scanf("%d", &choice4); switch (choice4) /*菜单选择*/ case 1 : system("cls");daysales();break; case 2 : system("cls");monthsales(); break ; case 3 :system("cls");yearsales(); break ; case 0 :system("cls");break; while (choice4!=0); printf("n");void loadsales() /*开始导入销售信息*/FILE *vfp;if(vfp=fopen("sales.txt","r")=NULL) /*打开文件*/printf("nnttt销售数据文件打开失败或文件不存在nn");return;shead=s2=s1=(struct sales*)malloc(VLEN);while(!feof(vfp)S+;fscanf(vfp,"%f ",&s2->count);s1=(struct sales*)malloc(VLEN); s2->snext=s1;s2=s1;s1=NULL;s2->snext=NULL;free(s2);printf("nnttt项销售信息已经由系统自动载入.nnnnttt",S);rewind(stdin);/*清空缓冲区*/if(fclose(vfp)printf("文件关闭失败!n");exit(0);void daysales()void monthsales()void yearsales()void listsales()s2=shead;printf("nntt *当前销售信息*n");printf("nn 销售额 nn");while(s2->count!=NULL)printf("%f",s2->count);s2=s2->snext;(s2->snext)=s2=NULL;printf("n");printf("销售信息列出完毕,按回车键返回子菜单:");rewind(stdin);/*清空缓冲区*/getchar();system("cls"); void loadvip() /*开始导入会员信息*/FILE *vfp;if(vfp=fopen("1.txt","r")=NULL) /*打开文件*/printf("nnvip数据文件打开失败或文件不存在n");printf("nn按回车键继续:");getchar();return;vhead=v2=v1=(struct vip*)malloc(VLEN);while(!feof(vfp)V+;fscanf(vfp,"%s %s %d %f %f",&v2->vnum,&v2->vname,&v2->level,&v2->persum,&v2->discount);v1=(struct vip*)malloc(VLEN); v2->vnext=v1;v2=v1;v1=NULL;v2->vnext=NULL;free(v2);printf("nnttt%d项会员信息已经由系统自动载入.nnnnttt按任意键显示主菜单:",V);rewind(stdin);/*清空缓冲区*/getchar();if(fclose(vfp)printf("文件关闭失败!n");exit(0);void listvip()v2=vhead;if(v2=NULL|V=0)/*文件不存在或书库中没书*/printf("nnnntttt当前书库没书!");printf("nntt按回车键返回:");rewind(stdin);/*清空缓冲区*/getchar();return;elseprintf("nntt *当前书库信息*n");printf("nn会员号 姓名 等级 会员总消费 会员折扣nn");while(v2->discount!=NULL)printf("%-18s%-10s%-5d %-6.2f %-5fn",v2->vnum,v2->vname,v2->level,v2->persum,v2->discount);v2=v2->vnext;printf("n");printf("会员信息列出完毕,按回车键返回子菜单:");rewind(stdin);/*清空缓冲区*/getchar();system("cls"); void buy() system("cls"); /*系统清屏*/ int choice1; do printf(" "); /*显示菜单*/printf(" *销售管理* "); printf(" ");printf(" ");printf(" 功能选项: n");printf(" 1 : 会员购买 n");printf(" 2 : 非会员购买 n");printf(" 0 : 返回主界面 n");printf(" ");printf("t请选择操作:"); scanf("%d", &choice1); switch (choice1) /*菜单选择*/ case 1 : system("cls");buy_by_huiyuan();break; case 2 : system("cls");buy_by_feihuiyuan(); break ; case 0 :system("cls");break; while (choice1!=0); printf("n");void buy_by_huiyuan()/*会员买书*/ time_t timep;char vipnum6; struct tm *p; time(&timep); p = gmtime(&timep);char bnum11;char ch;int i=0;float sum=0;/*保存所购买书的总费*/v1=vhead;printf("nnnnnnnnnnnttt请输入会员号码:");scanf("%s",vipnum);while(v1!=NULL)if(strcmp(vipnum,v1->vnum)=0)break;else v1=v1->vnext;if(v1=NULL)printf("对不起,你所输入的会员号不存在");if(p1=NULL|T=0)/*文件不存在或书库中没书*/printf("nnnnnnnnnntttt当前书库没书!");printf("nntttt按任意键返回:");rewind(stdin);/*清空缓冲区*/getch();return;p5=p4=head2=(struct book*)malloc(LEN);p4->next=NULL;system("cls");printf("nntt收费标准:一级会员打9折 二级会员打8折nnttt三级会员打7折 四级会员打6折 ");doprintf("nn请输入所需购买的书的书号(图书编号):");/*书号唯一*/rewind(stdin);/*清空缓冲区*/gets(bnum);p1=head;while(p1!=NULL)if(strcmp(p1->bnum,bnum)=0)break;else p1=p1->next;if(p1=NULL)system("cls");printf("nnnnnnnnnnt 没有找到该书信息,可能书号输入有误,是否再次输入书号?nn");printf("nnttt Y.是 N.否");rewind(stdin);/*清空缓冲区*/ch=getchar();if(ch='y'|ch='Y')system("cls");buy_flag=1;/*防止在此函数中调用时,search()函数执行了清屏*/search();/*调用查询,通过其他途径确定书号*/while(1)printf("nnttt提示:若没有您要找的书,可按0结束!");printf("nntttt请重新输入书号:");rewind(stdin);/*清空缓冲区*/gets(bnum);if(strcmp(bnum,"0")=0) break;/*没有需要的书,结束输入书号*/p1=head;while(p1!=NULL)if(strcmp(p1->bnum,bnum)=0) break;else p1=p1->next;if(p1!=NULL) break;system("cls");if(p1!=NULL) if(p1->acount=0) printf("nntttt该书已售完!");while(p1!=NULL)if(strcmp(p1->bnum,bnum)=0)/*有相同书号,循环提前结束*/break;else p1=p1->next;if(p1!=NULL&&p1->acount!=0)*p4=*p1;sum=sum+p4->price;p5=(struct book*)malloc(LEN);p4->next=p5;p6=p4;p4=p5;p4->next=NULL;i+;/*记录买的本数i,*/p1->acount=p1->acount-1;/*减去售过的书(本数)*/p4=head2;system("cls");printf("nnt*当前已选购书状态*");printf("nn书号 书名作者 售价 数量 总费nn");while(p4->next!=NULL)/*显示已买过的书*/printf("%-15s%-25s%-15s %.2f %d %.2fn",p4->bnum,p4->bname,p4->author,p4->price,p4->acount,sum);p4=p4->next;printf("nntt 提示:可按N结束购书,按任意键继续购书:");rewind(stdin);/*清空缓冲区*/ch=getchar();system("cls");while(ch!='n'&&ch!='N');/*结束购书*/free(p4);p5->next=NULL;if(head2->next=NULL) printf("nnnnnnnnnntttt您当前没有购书!nn");elseprintf("nnnnnnnnnnttt 确认购买这%d本书吗?n",i);printf("nnttt 按任意键确认,按N撤销购书:");/*不想购买时,亦可撤销*/rewind(stdin);/*清空缓冲区*/ch=getchar();if(ch='n'|ch='N')for(p4=head2;p4!=NULL;p4=p4->next)for(p1=head;p1!=NULL;p1=p1->next)if(strcmp(p1->bnum,p4->bnum)=0)p1->acount=p1->acount+1; /*书未销售,本数加上*/printf("nntttt 撤销完毕!");elseprintf("nnttt您所购买的书的总费(打折前)为%.2fnn",sum);printf("nnttt你的会员等级为%d级,可以享受%.1f折.nn",v1->level,(v1->discount)*10);printf("购买书本的折后价为%.2f.nn",(v1->discount)*sum);save_flag=1;/*书库信息变动标志*/printf("%d.%d.%dn", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday);rewind(stdin);/*清空缓冲区*/printf("nnttt 按回车键返回主菜单");getchar();void buy_by_feihuiyuan()/*非会员买书*/char bnum11;char ch;int i=0;float sum=0;/*保存所购买书的总费*/p1=head;if(p1=NULL|T=0)/*文件不存在或书库中没书*/printf("nnnnnnnnnntttt当前书库没书!");printf("nntttt按任意键返回:");rewind(stdin);/*清空缓冲区*/getch();return;p5=p4=head2=(struct book*)malloc(LEN);p4->next=NULL;doprintf("nn请输入所需购买的书的书号(图书编号):");/*书号唯一*/rewind(stdin);/*清空缓冲区*/gets(bnum);p1=head;while(p1!=NULL)if(strcmp(p1->bnum,bnum)=0)break;else p1=p1->next;

    注意事项

    本文(c语言图书销售系统(源代码).doc)为本站会员(豆****)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开