***************************************************/
/*********** M_BOOK.C + S_BOOK.C ******************/
#include <stdlib.h>
struct node
{ char name[10];
int price;
char pub[15];
};
extern struct node *add(),*del(struct node *);
extern struct node *load(),*mhdel(struct node *);
/*******************************************************/
/* 函数功能:显示菜单,选择菜单 */
/* 输入参数:无 */
/* 函数输出:选择的菜单序号 */
/*******************************************************/
int menu_select()
{
int cn=0;
printf(" **********************************************\n");
printf("\t\t 1. Add a book\n");
printf("\t\t 2. Display book library\n");
printf("\t\t 3. Query a book\n");
printf("\t\t 4. Delete a book\n");
printf("\t\t 5. Save to disk\n");
printf("\t\t 6. Load from disk \n");
printf("\t\t 7. Mohu search\n");
printf("\t\t 8. Mohu delete\n");
printf("\t\t 0. Exit\n");
printf("\t***********************************************\n");
printf("\n Input(0~8): ");
for(; ;)
{ scanf("%d",&cn);
if (cn<0 ||cn>8) printf("Error ! Input again(1~6):");
else
break;
}
return cn;
}
void main(void)
{
struct node *head=NULL;
for(; ;)
{ clrscr();
switch(menu_select())
{
case 1: head=add(head);break;
case 2: print(head);break;
case 3: search(head);break;
case 4: head= del(head);break;
case 5: save(head);break;
case 6: head=load();break;
case 7: mhsearch(head);break;
case 8: head=mhdel(head);break;
case 0: exit(0);
}
}
}