b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

小型图书管理系统C语言程序

电脑杂谈  发布时间:2019-08-07 21:16:02  来源:网络整理

c语言程序设计 图书管理系统_c语言简单图书管理系统_c语言图书管理系统

大型书店管理功能 C 语言程序 #include<stdio。h> #include<string。h> #include<stdlib。h> struct book { char writer[20]; char title[20]; char publishinghouse[20]; char number[10]; float price; struct book * next; }; struct book * Create_Book(); void Insert(struct book * head); void Delete(struct book * head); void Print_Book(struct book * head); void search_book(struct book * head); void change_Book(struct book * head); void save(struct book * head); struct book * Create_Book() {struct book * head; head=(struct book *)malloc(sizeof(struct book)); head->next=NULL; return head; } void save(struct book * head) { struct book *p; FILE *fp; p=head; fp=fopen("kucun。

c语言程序设计 图书管理系统_c语言简单图书管理系统_c语言图书管理系统

txt","w+"); fprintf(fp,"************************************************\n"); fprintf(fp,"书号\t 书名\t 作者\t 出版社\t 价格\t\n"); fprintf(fp,"\n"); while(p->next!= NULL) { p=p->next; fprintf(fp,"%s\t %s\t%s\t %s\t %。2f\t\n",p->number,p->title,p->writer,p->publishinghouse,p->price); } fprintf(fp,"************************************************\n"); fclose(fp); printf("已将书籍数据保留到 kucun。txt 文件\n");} //插入// void Insert(struct book *head) { struct book *s, *p,*p1,*swap; char flag='Y'; swap=(struct book *)malloc(sizeof(struct book)); p1=swap; p=head; while(flag=='Y'||flag=='y') { s=(struct book *)malloc(sizeof(struct book)); printf("\n请输入图书书号:"); fflush(stdin); scanf("%s",s->number); printf("\n请输入图书书目:"); fflush(stdin); scanf("%s",s->title); printf("\n请输入图书作者名:"); fflush(stdin); scanf("%s",s->writer); printf("\n请输入图书出版社:"); fflush(stdin);scanf("%s",s->publishinghouse); printf("\n请输入图书价格:"); fflush(stdin); scanf("%f",&s->price); printf("\n"); //排序// p1=p->next; if(head->next!=NULL) do { if(strcmp((p1->number),(s->number))>) {strcpy(swap->number,p1->number);strcpy(swap->title,p1->title);strcpy(swap->writer,p1->writer);strcpy(swap->publishinghouse,p1->publishinghouse);swap->price=p1->price;strcpy(p1->number,s->number);strcpy(p1->title,s->title);strcpy(p1->writer,s->writer);strcpy(p1->publishinghouse,s->publishinghouse);p1->price=s->price;strcpy(s->number,swap->number);strcpy(s->title,swap->title);strcpy(s->writer,swap->writer);strcpy(s->publishinghouse,swap->publishinghouse);s->price=swap->price; } p=p1;p1=p->next; }while(p1!=NULL); p->next=s; s->next=NULL; printf("******* 添加成功!*******"); printf("\n继续添加?(Y/N):"); fflush(stdin); scanf("%c",&flag); printf("\n"); if(flag=='N'||flag=='n') {break;} else if(flag=='Y'||flag=='y') {continue;} } save(head);} //查找// void search_book(struct book *head) { struct book * p; char temp[20]; p=head; if(head==NULL || head->next==NULL) { printf("******* 图书馆为空!*******\n"); } else { printf("请输入您要查找的新书: "); fflush(stdin); scanf("%s",temp); while(p->next!= NULL) { p=p->next; if(strcmp(p->title,temp)==) {printf("\n 图书已寻找!\n");printf("\n");printf("书号: %s\t\n",p->number);printf("名著: %s\t\n",p->title);printf("作者名: %s\t\n",p->writer);printf("出版社: %s\t\n",p->publishinghouse);printf("低价: %。

c语言简单图书管理系统_c语言程序设计 图书管理系统_c语言图书管理系统

2f\t\n",p->price); } if(p->next==NULL) {printf("\n 查询完毕!\n"); } } } }void Print_Book(struct book * head){struct book * p;if(head==NULL || head->next==NULL){printf("\n******* 没有图书记录! *******\n\n");}p=head;printf("*************************************\n"); printf(" 书号\t 书名\t 作者\t 出版社\t 价格\t\n"); printf("*************************************\n"); while(p->next!= NULL) { p=p->next; printf("%s\t%s\t%s\t%s\t%。

c语言简单图书管理系统_c语言图书管理系统_c语言程序设计 图书管理系统

2f\t\n",p->number,p->title,p->writer,p->publishinghouse,p->price); } printf("*************************************\n"); printf("\n"); } //更改// void change_Book(struct book * head) { struct book * p; int panduan=0; char temp[20]; p=head; printf("请输入要修改图书的书号:"); scanf("%s",temp); while(p->next!= NULL){p=p->next; if(strcmp(p->number,temp)==) {printf("\n请输入图书书目:");fflush(stdin);scanf("%s",p->title);printf("\n请输入图书作者名:");fflush(stdin);scanf("%s",p->writer);printf("\n请输入图书出版社:");fflush(stdin);scanf("%s",p->publishinghouse);printf("\n请输入图书价格:");fflush(stdin);scanf("%f",&p->price);printf("\n");panduan=1;}}if(panduan==0){ printf("\n******没有图书记录!******\n\n");} } //删除// void Delete(struct book *head){ struct book *s,*p; char temp[20]; int panduan; panduan=0; p=s=head; printf("[请输入您要删除的新书]:"); scanf("%s",temp); p=p->next; while(p!= NULL) { if(strcmp(p->title,temp)==) { panduan=1; break; } p=p->next; } if(panduan==1) { while(s->next!=p) { s=s->next;} s->next=p->next; free(p); printf("\n******* 删除成功!*******\n"); save(head); } else { printf("您输入的书籍不存在c语言简单图书管理系统,请确定后输入!\n"); } } //主函数// void main() { struct book * head;int choice; head=NULL; while(1) { printf("*************************************************\n");printf("*小型书店管理功能*\n"); printf("**\n"); printf("*[1]书籍资料录入*\n"); printf("**\n"); printf("*[2]书籍资料浏览*\n"); printf("**\n"); printf("*[3]书籍资料检索*\n"); printf("**\n"); printf("*[4]书籍资料修改*\n"); printf("**\n"); printf("*[5]书籍资料删除*\n"); printf("**\n");printf("*[6] 退 出 系 统*\n"); printf("*************************************************\n"); printf("请选择:"); fflush(stdin); scanf("%d",&choice); switch (choice) { case 1: if(head==NULL) {head=Create_Book(); } Insert(head); break; case 2: Print_Book(head); break; case 3: search_book(head); break; case 4:change_Book(head); break; case 5: Delete(head); break; case 6: printf("\n"); printf("******* 感谢使用书籍管理功能 ******\n"); break; default:printf("******* 输入错误c语言简单图书管理系统,请再次输入!*******");break; } } }


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-118410-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...