#include #include #include //书的结构体 struct book { char book_name[30];//书名 C语言 int bianhao;//书的编号 double 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; }; //创建新的图书库,图书编号输入为0时结束 struct book* Create_New_Book();//函数的声明 //创建新的会员,会员学号输入为0时结束 struct club *Create_New_Club(); int main() { struct book* head_book; struct club *head_club; printf('\n欢迎你第一次进入图书管理系统\n\n'); printf('------>新建图书库\n\n'); printf('创建新的图书库,图书编号输入为0时结束\n\n'); head_book=Create_New_Book(); system('cls'); printf('\n欢迎您第一次进入图书管理系统!\n\n'); printf('----->[向导]----->[新建会员库]\n\n'); printf('注意:当输入会员学号为0时,进入主菜单.\n\n'); head_club=Create_New_Club(); system('cls'); 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('请输入图书名称:'); scanf('%s',book_name); printf('请输入图书编号:'); scanf('%d',&bianhao); printf('请输入图书单价:'); scanf('%lf',&price); printf('请输入作者名字:'); scanf('%s',author); printf('\n'); while(bianhao!=0) { p_book=(struct book*)malloc(size_book); strcpy(p_book->book_name,book_name); p_book->bianhao=bianhao; p_book->price=price; strcpy(p_book->author,author); p_book->xuehao=0; strcpy(p_book->state,'存在'); strcpy(p_book->sex,'待定'); strcpy(p_book->name,'待定'); printf('请输入图书名称:'); scanf('%s',book_name); printf('请输入图书编号:'); scanf('%d',&bianhao); printf('请输入图书单价:'); scanf('%lf',&price); printf('请输入作者名字:'); scanf('%s',author); printf('\n'); } 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('请输入会员名字:'); scanf('%s',name); printf('请输入会员性别:'); scanf('%s',sex); printf('请输入会员学号:'); scanf('%d',&xuehao); printf('\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,'暂无'); printf('请输入会员名字:'); scanf('%s',name); printf('请输入会员性别:'); scanf('%s',sex); printf('请输入会员学号:'); scanf('%d',&xuehao); printf('\n'); } return head_club; }
联系客服