Current location - Training Enrollment Network - Books and materials - How to write the resume of the second-hand book management system
How to write the resume of the second-hand book management system
# include # includestructBook { char number[ 15]; char writer[ 10]; charname[50]; }; void eatline(){ charch; while((ch=getchar())! ='\n') Continue; }intaddbook(Book*b, int*n){puts ("Please enter ISBN:"); Get (b[*n]. No.); Puts ("Please enter author:"); Get (b[*n]. Writer); Puts ("Please enter a title:"); Get (b[*n]. Name); * n = * n+ 1; return0}intdeletebook(Book*b,int * n){ chars[50]; inti,j,flag = 0; Puts ("Please enter the title of the book you want to delete:"); Obtain; for(I = 0; I<* n;; i++){if(strcmp(b[i])。 name,s)= = 0){ for(j = I; j & lt* n- 1; J++){strcpy(b[j]. No.,b[j+ 1]. No.); strcpy(b[j].writer,b[j+ 1]。 Writer); Strcpy(b[j]. Name, b[j+ 1]. Name); } flag = 1; }}if(flag== 1){puts ("This book has been deleted! ! !" ); * n = * n- 1; Return0}else{puts ("The book you want to delete does not exist! ! !" ); return 1; }}intsearch(Book*b,intn,char * str){ inti; for(I = 0; I & ltn;; I++) {if (strcmp (b [I])。 Name, str) = = 0) {printf ("Book number:% s \ Author:% s \ nTitle:% s \ n", b [I]. Number, b [I]. Writer,b[returni; }}printf ("There is no book you are looking for \ n"); return- 1; }intmodifym(Book*b,int * n){ charnu[ 15]; charw[ 10]; charna[50]; IntflagPuts ("Please enter the title of the book you want to modify:"); gets(na); If ((flag = search (b, * n, na)) =- 1) {printf ("The book you want to modify does not exist! ! ! \ n "); return- 1; }else{puts ("Please enter a new ISBN:"); While (gets (nu), strcmp (nu, "") = = 0) {puts ("Your input is wrong, please re-enter:"); }puts ("Please enter a new author:"); While (gets (w), strcmp (w, "") = = 0) {puts ("Your input is wrong, please re-enter:"); }puts ("Please enter a new title:"); While (gets (na), strcmp (na, "") = = 0) {puts ("Your input is wrong, please re-enter:"); }strcpy(b[flag]。 No.,nu); Strcpy(b[flag]. Writer, W); Strcpy(b[flag]. Name, na); Return 0}} Voidprintmenu () {printf ("\ t \ t1,add book information \ n"); Printf("\t\t2, query book information \ n "); Printf("\t\t3, delete book information \ n "); Printf("\t\t4, modify book information \ n "); Printf("\t\t5, printing book information \ n "); Printf("\t\t0, exit the system \ n "); }intprintmessage(Book*b,intn){ inti; for(I = 0; I & ltn;; i++){ printf(" ISBN:"); puts(b[i]。 No.); Printf ("Author:"); puts(b[i]。 Writer); printf(" Title:"); puts(b[i]。 Name); } return0} int main(){ book book[50]; charstr[20]; Intn=0, flag; print menu(); While(scanf("%d ",& flag), flag! = 0){ eat line(); switch(flag){ case 1:addbook(book & amp; n); Break; Case2:printf ("Please enter the title you are looking for:"); gets(str); search(book,n,str); Break; Situation 3: Delete a book. n); Break; Situation 4: Modify (Book & AMPN); Situation 5:printmessage(book, n); Break; Default: break} printmenu (); } return0}