This is my freshman second semester at the beginning of the C language course design works, hey, originally thought has not found the manuscript, today inadvertently unexpectedly in QQ network hard disk found the original version of the Teta, published in this, in order to commemorate.
C source code such as the following:
#include <stdio.h> #include <stdlib.h> #include <string.h>struct book{char book_name[30];int Bianhao ;d ouble price;char author[20];char state[20];char name[20];char sex[10];int xuehao;struct book *book_next;}; struct Club{char name[20];char sex[10];int xuehao;char borrow[30];struct club *club_next;}; void Print_book (struct book *head_book);/* Browse all book information */void print_club (struct Club *head_club);/* View all member Information */struct book * Create_new_book ();/* Create a new library, the book number input is 0 o'clock end */struct books *search_book_bianhao (int bianhao,struct book *head_book); struct book *search_book_name (char *b_name,struct book *head_book); the struct book *search_book_price (double Price_h, Double price_l,struct book *head_book); the struct books *insert_book (struct, *head_book,struct);/* Add a library, Join */struct book *delete_book (struct books *head_book,int Bianhao) one by one; */* Delete Library */struct club *create_new_club (); struct Club * Search_club_xuehao (int xuehao,struct club *head_club), struct Club *search_club_name (char *c_name,struct club *hEad_club), struct club *insert_club (struct Club *head_club,struct club *stud_club), struct club *delete_club (struct club * Head_club,int Xuehao); struct book *lent_book (int. bianhao,int xuehao,struct Book *head_book,struct club *head_club); struct Book *back (int. bianhao,int xuehao,struct Book *head_book,struct club *head_club), int main () {struct book *head_book , *p_book;char book_name[30],name[20],author[20],sex[10];int bianhao;double price,price_h,price_l;int size_book= sizeof (struct book), int m=1,n=1,f;char *b_name,*c_name;struct Club *head_club,*p_club;int Xuehao;int size_club=sizeof (struct club); int choice; printf ("/n welcome your first entry into the book Management System!/n/n");p rintf ("----->[Wizard"----->[new Library]/n/n ");p rintf (" Note: When you enter the book number 0 o'clock, go to the next step./n/n ") ; Head_book=create_new_book (); System ("CLS");p rintf ("/n welcome your first access to the book Management System!/n/n");p rintf ("----->[Wizard"----->[ New Member Library]/n/n ");p rintf (" Note: When entering the membership number is 0 o'clock, go to the main menu./n/n "); Head_club=create_new_club (); System (" CLS ");d o{printf ("/n/t/t/t〓 〓〓〓〓 Book Management system 〓〓〓〓〓/n/n ");p rintf ("/n ");p rintf ("/t/t/t[1]: Borrowing for/t ");p rintf ("[6]: Return book for/n");p rintf ("/n");p rintf ("/t/t/t[2]: Query book/t");p rintf ("[7]: Query member/n");p rintf ("/t/t/t[3]: Add books/T") ;p rintf ("[8]: Join member/n");p rintf ("/t/t/t[4]: Delete book/T");p rintf ("[9]: Delete member/n");p rintf ("/t/t/t[5]: Traverse book/T");p rintf ("[10]: Traverse member/n/n ");p rintf ("/t/t/t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓/n/n ");p rintf ("/t/t/t0: Exit/n/n ");p rintf (" Please select <0~10>: "); scanf ("%d " , &choice), switch (choice) {case 1:printf ("/n/t/t/t〓〓〓〓〓 Book Management System 〓〓〓〓〓/n/n");p rintf ("Enter the borrowed book Number:/n"); scanf ("%d", &bianhao);p rintf ("Enter the borrower's school number:/n"), scanf ("%d", &xuehao); Head_book=lent_book (Bianhao,xuehao,head_book,head_ Club), System ("CLS");p rintf ("/N Borrowing Success!/n/n");p rintf ("Related information such as the following:/n/n"); Head_book=search_book_bianhao (Bianhao,head_ book); Break;case 2:system ("CLS");p rintf ("/n/t/t/t〓〓〓〓〓 Library Management System 〓〓〓〓〓/n/n");p rintf ("1. Query/n/n by number");p rintf ("2. Query by name/n /n ");p rintf (" 3. Query/n/n by Price range ");p rintf (" 0. Return to main Menu/n/n ");p rintf (" Please select: "); scanf ("%d ", &f); if (f==1) {printf (" Please enter the enquiry Book Number: "); scanf ("%d", &bianhao); printf ("Related information such as the following:/n/n"); Head_book=search_book_bianhao (Bianhao,head_book); break;} else if (f==2) {B_name=book_name;getchar ();p rintf ("Please enter query Book name:"); Gets (B_name); printf ("Related information such as the following:/n/n"); Head_book=search_book_name (B_name,head_book); break;} else if (f==3) {printf ("Please enter the highest price:"), scanf ("%lf", &price_h);p rintf ("Please enter the lowest price:"), scanf ("%lf", &price_l);p rintf ( "Relevant information such as the following:/n/n"); Head_book=search_book_price (price_h,price_l,head_book); break;} else if (f==0) {break;} Break;case 6:printf ("/n/t/t/t〓〓〓〓〓 Book Management System 〓〓〓〓〓/n/n");p rintf ("Enter the same book number:/n"), scanf ("%d", &bianhao);p rintf (" Enter the study number of the returning person:/n "), scanf ("%d ", &xuehao), Head_book=back (Bianhao,xuehao,head_book,head_club), System (" CLS ");p rintf ( "/N Return Success!/n/n");p rintf ("Related information such as the following:/n/n"); Head_book=search_book_bianhao (Bianhao,head_book); Break;case 3:system (" CLS ");p rintf ("/n/t/t/t〓〓〓〓〓 Book Management System 〓〓〓〓〓/n/n ");p rintf (" Please enter book name: "); scanf ("%s", book_name); printf ("Please enter the book Number:"); scanf ("%d", &bianhao); printf ("Please enter Unit Price:"); scanf ("%lf", &price); printf ("Please enter the author's name:"); scanf ("%s", author); printf ("/n");struct book *ptr_b; for (Ptr_b=head_book;ptr_b;ptr_b=ptr_b->book_next) {if (Ptr_b->bianhao==bianhao) {printf ("This numbered book already exists/n"); m=0; Break;}} if (m) {p_book= (struct book *) malloc (Size_book); strcpy (P_book->book_name,book_name); p_book->bianhao=bianhao; p_book->price=price; p_book->xuehao=0; strcpy (P_book->author,author); strcpy (p_book->state, "existence"); strcpy (P_book->sex, "TBD"); strcpy (P_book->name, "Pending"), Head_book=insert_book (Head_book,p_book);p rintf ("/n Join Book Success!/n/n");} Break;case 4:system ("CLS");p rintf ("/n/t/t/t〓〓〓〓〓 Book Management System 〓〓〓〓〓/n/n");p rintf ("Enter delete book Number:/n"); scanf ("%d", &bianhao ); Head_book=delete_book (Head_book,bianhao);p rintf ("/n Delete book success!/n/n"), Break;case 5:system ("CLS");p rintf ("/n/t/t/t〓 〓〓〓〓 Book Management system 〓〓〓〓〓/n/n "); Print_book (Head_book) break;case 7:system ("CLS");p rintf ("/n/t/t/t〓〓〓〓〓 Book Management System 〓〓〓〓〓/n/n");p rintf ("1. Inquiry/n/n by study number"); printf ("2. Query/n/n by name");p rintf ("0. Return to main Menu/n/n");p rintf ("Please select:"); scanf ("%d", &f); if (f==1) {printf ("Please enter Inquiry membership number:"); scanf ("%d", &xuehao); printf ("Related information such as the following:/n/n"); Head_club=search_club_xuehao (Xuehao,head_club); break;} else if (f==2) {C_name=name;getchar ();p rintf ("Please enter query member name:"); Gets (C_name); printf ("Related information such as the following:/n/n"); Head_club=search_club_name (C_name,head_club); break;} else if (f==0) {break;} break;printf ("Please enter Inquiry membership number:/n"), scanf ("%d", &xuehao);p rintf ("Related information such as the following:/n/n"), Break;case 8:system ("CLS");p rintf ( "/n/t/t/t〓〓〓〓〓 Book Management System 〓〓〓〓〓/n/n");p rintf ("Please enter the member name:"); scanf ("%s", name); printf ("Please enter the Membership Gender:"); scanf ("%s", sex); printf ("Please enter the membership number:"); scanf ("%d", &xuehao); printf ("/n"); struct club *ptr_c; for (Ptr_c=head_club;ptr_c;ptr_c=ptr_c->club_next) {if (Ptr_c->xuehao==xuehao) {printf ("This number member already exists/n"); n=0; Break;}} if (n) {p_club= (struct club *) malloc (sizeof (struct club)); strcpy (P_club->name,name); strcpy (P_club->sex,sex); p_club->xuehao=xuehao; strcpy (P_club->borrow, "no"), Head_club=insert_club (Head_club,p_club);p rintf ("/N Join member Success!/n/n");} Break;caSe 9:system ("cls");p rintf ("/n/t/t/t〓〓〓〓〓 Book Management System 〓〓〓〓〓/n/n");p rintf ("Enter to delete membership number:/n"); scanf ("%d", &xuehao); Head_ Club=delete_club (Head_club,xuehao);p rintf ("/n Delete member Success!/n/n"), Break;case 10:system ("CLS");p rintf ("/n/t/t/t〓〓〓〓〓 Library Management System 〓〓〓〓〓/n/n "); Print_club (Head_club) break;case 0:system ("CLS");p rintf ("/n/t/t/t〓〓〓〓〓 Book Management System 〓〓〓〓〓/n/n");p rintf ("/n Thank you for using!/n/n") ; break;}} while (choice!=0); return 0;} struct Book *create_new_book () {struct book *head_book,*p_book;int bianhao;double Price;char book_name[30],author[20]; int size_book=sizeof (struct book); head_book=null;printf ("Please enter the name of the library:"), scanf ("%s", Book_name);p rintf ("Please enter the book Number:"); scanf ("%d", &bianhao);p rintf ("Enter Unit Price:"), scanf ("%lf", &price);p rintf ("Please enter the author's name:"); scanf ("%s", author); printf ("/n"); bianhao!=0 {p_book= (struct book *) malloc (Size_book); strcpy (P_book->book_name,book_name);p _ book->bianhao=bianhao;p_book->price=price;p_book->xuehao=0;strcpy (P_book->author,author); strcpy (p_ Book->state, "presence"), strcpy (P_book->sex, "TBD"); strcpy (p_book->name, "Pending"), Head_book=insert_book (Head_book,p_book);p rintf ("Please enter book Name:"), scanf ("%s", Book_name);p rintf (" Please enter the book Number: "), scanf ("%d ", &bianhao);p rintf (" Enter Unit Price: "), scanf ("%lf ", &price);p rintf (" Please enter the author's name: "), scanf ("%s ", Author);p rintf ("/n");} return Head_book;} struct Book *search_book_bianhao (int. bianhao,struct book *head_book) {struct book *ptr_book;int flag=0;for (ptr_book= Head_book;ptr_book;ptr_book=ptr_book->book_next) {if (Ptr_book->bianhao==bianhao) {printf ("Book Number:%d/n", ptr_ Book->bianhao);p rintf ("Book Name:%s/n", Ptr_book->book_name);p rintf ("book Unit Price:%.2lf/n", Ptr_book->price); printf ("book Author:%s/n", Ptr_book->author);p rintf ("Presence Status:%s/n", ptr_book->state);p rintf ("Borrower name:%s/n", ptr_book- >name);p rintf ("Borrower's Gender:%s/n", Ptr_book->sex);p rintf ("study number:%d/n", Ptr_book->xuehao);p rintf ("/n"); flag++;}} if (flag==0) {printf ("No such book Information!/n/n");} return Head_book;} struct book *search_book_name (char *b_name,struct book *head_book) {struct book *ptr_book;int flag=0;for (Ptr_book=head_ Book;ptr_book;ptr_book=ptr_booK->book_next) {if (strcmp (ptr_book->book_name,b_name) ==0) {printf ("Book Number:%d/n", Ptr_book->bianhao);p rintf ( "Book Name:%s/n", Ptr_book->book_name);p rintf ("book Unit Price:%.2lf/n", Ptr_book->price);p rintf ("book Author:%s/n", ptr_book- >author);p rintf ("Presence Status:%s/n", ptr_book->state);p rintf ("Borrower name:%s/n", Ptr_book->name);p rintf ("Borrower's Gender:%s/n", Ptr_book->sex);p rintf ("Study No.:%d/n", Ptr_book->xuehao);p rintf ("/n"); flag++;}} if (flag==0) {printf ("No such book Information!/n/n");} return Head_book;} struct book *search_book_price (double price_h,double price_l,struct book *head_book) {struct book *ptr_book;int flag=0; for (Ptr_book=head_book;ptr_book;ptr_book=ptr_book->book_next) {if (ptr_book->price>=price_l) && (Ptr_book->price<=price_h)) {printf ("Book Number:%d/n", Ptr_book->bianhao);p rintf ("Book Name:%s/n", Ptr_book->book_name);p rintf ("book Unit Price:%.2lf/n", Ptr_book->price);p rintf ("book Author:%s/n", Ptr_book->author);p rintf ("Existence Status:%s/n", ptr_book->state);p rintf (" Borrower's name:%s/n ", Ptr_book->name);p rintf (" Borrower Sex:%s/n ", Ptr_book-> sex);p rintf ("%d/n", Ptr_book->xuehao);p rintf ("/n"); flag++;}} if (flag==0) {printf ("No such book Information!/n/n");} return Head_book;} struct book *delete_book (struct book *head_book,int Bianhao) {struct book *ptr1_book,*ptr2_book;while (Head_book!=null & amp;& Head_book->bianhao==bianhao) {ptr2_book=head_book;head_book=head_book->book_next;free (Ptr2_book) ;} if (head_book==null) return Null;ptr1_book=head_book;ptr2_book=head_book->book_next;while (Ptr2_book!=NULL) {if ( Ptr2_book->bianhao==bianhao) {ptr1_book->book_next=ptr2_book->book_next;free (ptr2_book);} Elseptr1_book=ptr2_book;ptr2_book=ptr1_book->book_next;} return Head_book;} struct Club *create_new_club () {struct Club *head_club,*p_club;int Xuehao;char name[20],sex[10];int size_club=sizeof ( struct club), head_club=null;printf ("Enter member name:"), scanf ("%s", name);p rintf ("Please enter the Membership Gender:"), scanf ("%s", Sex);p rintf (" Please enter the membership number: "), scanf ("%d ", &xuehao);p rintf ("/n "), while (xuehao!=0) {p_club= (struct club *) malloc (size_club); strcpy ( P_club->name,name); strcpy (P_club->sex,sex);p _club->xuehao=xuehao;strcpy (P_club->borrow, "no"); Head_club=insert_club (head_club,p_ Club);p rintf ("Please enter the member name:"), scanf ("%s", name);p rintf ("Please enter the Membership Gender:") scanf ("%s", Sex);p rintf ("Enter the membership number:"); scanf ("%d", &xuehao);p rintf ("/n");} return head_club;} struct Club *search_club_xuehao (int xuehao,struct club *head_club) {struct Club *ptr_club;int flag=0;for (ptr_club=head_ Club;ptr_club;ptr_club=ptr_club->club_next) {if (Ptr_club->xuehao==xuehao) {printf ("Member Name:%s/n", ptr_club- >name);p rintf ("Member Gender:%s/n", Ptr_club->sex);p rintf ("Membership Number:%d/n", Ptr_club->xuehao);p rintf ("borrowed book:%s/n", ptr_ Club->borrow);p rintf ("/n"); flag++;}} if (flag==0) {printf ("This user does not exist!/n/n");} return head_club;} struct Club *search_club_name (Char *c_name,struct club *head_club) {struct Club *ptr_club;int flag=0;for (ptr_club=head_ Club;ptr_club;ptr_club=ptr_club->club_next) {if (strcmp (ptr_club->name,c_name) ==0) {printf ("Member Name:%s/n", ptr_ Club->name);p rintf ("Member Gender:%s/n", Ptr_club->sex);p rintf ("Membership Number:%d/n", Ptr_club-> xuehao);p rintf ("borrowed book:%s/n", Ptr_club->borrow);p rintf ("/n"); flag++;}} if (flag==0) {printf ("This user does not exist!/n/n");} return head_club;} struct Book *lent_book (int. bianhao,int xuehao,struct Book *head_book,struct club *head_club) {struct book *ptr_book; struct Club *ptr_club;int flag=0;for (Ptr_book=head_book;ptr_book;ptr_book=ptr_book->book_next) for (ptr_club= Head_club;ptr_club;ptr_club=ptr_club->club_next) {if (Ptr_book->bianhao==bianhao) && (ptr_club-> Xuehao==xuehao)) {strcpy (ptr_book->name,ptr_club->name); /* Copy the string, copy the contents on the right to the left */strcpy (ptr_book->sex,ptr_club->sex);p tr_book->xuehao=ptr_club->xuehao;strcpy (Ptr_book->state, "temporary absence"); strcpy (ptr_club->borrow,ptr_book->book_name); flag++;} if (flag==0) {printf ("No such book or you have not yet registered as a member!/n/n");}} return Head_book;} struct Book *back (int. bianhao,int xuehao,struct Book *head_book,struct club *head_club) {struct Book *ptr_book;struct club *ptr_club;int flag=0;for (Ptr_book=head_book;ptr_book;ptr_book=ptr_book->book_next) for (ptr_club=Head_club;ptr_club;ptr_club=ptr_club->club_next) {if (Ptr_book->bianhao==bianhao) && (ptr_club-> Xuehao==xuehao) {strcpy (Ptr_book->name, "no"), strcpy (Ptr_book->sex, "Pending");p tr_book->xuehao=0;strcpy (PTR _book->state, "no"), strcpy (Ptr_club->borrow, "no"); flag++;} if (flag==0) {printf ("input wrong, please retry/n/n");}} return Head_book;} struct book *insert_book (struct book *head_book,struct book *stud_book) {struct book *ptr_b,*ptr1_b,*ptr2_b;ptr2_b=head _book;ptr_b=stud_book;if (head_book==null) {head_book=ptr_b;head_book->book_next=null;} Else{while ((Ptr_b->bianhao > Ptr2_b->bianhao) && (ptr2_b->book_next!=null)) {PTR1_B=PTR2_B;PTR2 _b=ptr2_b->book_next;} if (Ptr_b->bianhao <= Ptr2_b->bianhao) {if (head_book==ptr2_b) Head_book=ptr_b;else ptr1_b->book_next=ptr _b;ptr_b->book_next=ptr2_b;} Else{ptr2_b->book_next=ptr_b;ptr_b->book_next=null;}} return Head_book;} struct Club *insert_club (struct Club *head_club,struct club *stud_club) {struct Club *ptr_c,*pTr1_c,*ptr2_c;ptr2_c=head_club;ptr_c=stud_club;if (head_club==null) {head_club=ptr_c;head_club->club_next= NULL;} Else{while ((Ptr_c->xuehao > Ptr2_c->xuehao) && (ptr2_c->club_next!=null)) {Ptr1_c=ptr2_c;ptr2_c =ptr2_c->club_next;} if (Ptr_c->xuehao <= Ptr2_c->xuehao) {if (Head_club==ptr2_c) Head_club=ptr_c;else ptr1_c->club_next=ptr_c ;p Tr_c->club_next=ptr2_c;} Else{ptr2_c->club_next=ptr_c;ptr_c->club_next=null;}} return head_club;} void Print_club (struct club *head_club) {struct Club *ptr_c;if (head_club==null) {printf ("/n No record/n/n"); return;} printf ("/n member name/T member gender/T Membership number/n/n"); for (Ptr_c=head_club;ptr_c;ptr_c=ptr_c->club_next) printf ("%s/t/t%s/t/t%d/n" , Ptr_c->name,ptr_c->sex,ptr_c->xuehao);} struct Club *delete_club (struct club *head_club,int Xuehao) {struct Club *ptr1_club,*ptr2_club;while (head_club!=null && Head_club->xuehao==xuehao) {ptr2_club=head_club;head_club=head_club->club_next;free (ptr2_club);} if (head_club==null) return null;ptr1_Club=head_club;ptr2_club=head_club->club_next;while (ptr2_club!=null) {if (Ptr2_club->xuehao==xuehao) {ptr1_ Club->club_next=ptr2_club->club_next;free (Ptr2_club);} Elseptr1_club=ptr2_club;ptr2_club=ptr1_club->club_next;} return head_club;} void Print_book (struct book *head_book) {struct book *ptr_b;if (head_book==null) {printf ("/n No record/n/n"); return;} printf ("/n Book number/t book name/t book unit Price/t book author/n/n"); for (Ptr_b=head_book;ptr_b;ptr_b=ptr_b->book_next) printf ("%d/t/t%s/ t/t%.2lf/t/t%s/n/n ", Ptr_b->bianhao,ptr_b->book_name,ptr_b->price,ptr_b->author);}
C Language Course design-book Management system