#include #include #include #include struct book{ char name[100]; char author[100]; char publisher[100]; char date[20]; double price; int quantity; }; //定义书类型的结构体 book aa[100]={{"周子越教你学高数","周子越","湖南工业大学出版社","2019.01.08",88,5000},{"失乐园","渡边淳一","文化艺术出版社","2005.04.01",24,100},{"C语言程序设计","刘强","电子工业出版社","2018.02.28",49,150},{"D语言程序设计","刘强","电子工业出版社","2018.02.28",49,150},{"E语言程序设计","刘强","电子工业出版社","2018.02.28",49,150}};//初始化五本书 int pp=6; //书的总数(控制循环次数) FILE *fp; void buy(); void start(); void print(); void update(); void print(){ //显示书籍存货清单函数 int i; system("cls"); system("color E0"); fp=fopen("booklist.txt","r"); for(i=0;ipp||s<1) { printf("\n\t\t\t范围输入错误!按任意键返回上一级"); getch(); update(); } else { for(i=pp;i>=s;i--) { aa[i+1]=aa[i]; } aa[s].price=0; aa[s].quantity=0; printf("\n\t\t\t请输入您要添加的书籍的名称:"); scanf("%s",aa[s].name); printf("\n\t\t\t请输入您要添加的书籍的作者:"); scanf("%s",aa[s].author); printf("\n\t\t\t请输入您要添加的书籍的出版社:"); scanf("%s",aa[s].publisher); printf("\n\t\t\t请输入您要添加的书籍的出版日期:"); scanf("%s",aa[s].date); printf("\n\t\t\t请输入您要添加的书籍的价格:"); scanf("%lf",&aa[s].price); printf("\n\t\t\t请输入您要添加的书籍的库存:"); scanf("%d",&aa[s].quantity); printf("\n\t\t\t\t书籍信息添加成功!"); pp++; fp = fopen("booklist.txt","w"); for(i=0;ipp||s<1) { printf("\n\t\t\t范围输入错误!按任意键返回上一级"); getch(); update(); } else { printf("\n\t\t\t请输入您要修改的书籍的名称:"); scanf("%s",aa[s-1].name); printf("\n\t\t\t请输入您要修改的书籍的作者:"); scanf("%s",aa[s-1].author); printf("\n\t\t\t请输入您要修改的书籍的出版社:"); scanf("%s",aa[s-1].publisher); printf("\n\t\t\t请输入您要修改的书籍的出版日期:"); scanf("%s",aa[s-1].date); printf("\n\t\t\t请输入您要修改的书籍的价格:"); scanf("%lf",&aa[s-1].price); printf("\n\t\t\t请输入您要修改的书籍的库存:"); scanf("%d",&aa[s-1].quantity); printf("\n\t\t\t\t书籍信息修改成功!"); fp = fopen("booklist.txt","w"); for(i=0;i