c语言图书管理系统求助
请问各路神仙,怎样在原来的基础上做出新书上架和旧书下架,添加与删除学生的模块
也就是我的struct Book和struct Card怎样才能输入的形式实现增加或者减少里面的数据呢?(现在各有五个)
我想输入第六个,或者删掉一个?要怎么做呢?
c语言初学,表达不完善请见谅
#include "stdio.h"
#include "string.h"
#include "windows.h"
struct Card
{
char card_num;
char student_name;
int book_totle;
};
struct Card card={{"20111101","Zhanjun",3},{"20111103","YangKai",1},{"20111113","WuGang",4},{"20111123","Shanglei",2},{"20111105","ZhangKun",5}};
struct Date
{
int year;
int month;
int day;
};
struct Book
{
char book_num;
char book_name;
struct Date date;
int flag;
};
struct Book book={{"305032","History",{0,0,0},1},{"409812","Geogrophy",{0,0,0},1},{"213401","English",{0,0,0},1},{"3287463","Maths",{0,0,0},1},{"4102102","Physicyl",{0,0,0},1}};
char num;
void menu();//函数的声明
void borrowbook();
void returnbook();
void bookinquiry();
void bookupdate();
void readerinquiry();
void readerupdate();
void reborrow();
void borrowbook()
{
int i;
char booknum;
printf("请输入要借阅的书号");
scanf("%s",booknum);
for(i=0;i<5;i++)
{
if(strcmp(booknum,book.book_num)==0)
{
if(book.flag==0)
printf("这本书已经借出!\n");
else
{
book.flag=0;
printf("借出日期填写:(请按年/月/日的顺序,如2019/9/8)\n");
scanf("%d/%d/%d",&book.date.year,&book.date.month,&book.date.day);
break;
}
}
}
for(i=0;i<5;i++)
if(strcmp(num,card.card_num)==0)
{ card.book_totle=card.book_totle+1;
break;
}
printf("1.确认并返回菜单 2.确认信息并退出\n");
scanf("%d",&i);
if(i==1)menu();
else exit(0);
}
void returnbook()
{
int i;
char booknum;
printf("请输入要还的书号");
scanf("%s",booknum);
for(i=0;i<5;i++)
{
if(strcmp(booknum,book.book_num)==0)
{
book.flag=1;
break;
}
if(i>=5)
printf("卡号输入错误!");
for(i=0;i<5;i++)
if(strcmp(num,card.card_num)==0)
{
card.book_totle=card.book_totle+1;
break;
}
printf("1.确认并返回菜单 2.确认信息并退出\n");
scanf("%d",&i);
if(i==1)menu();
else exit(0);
}
}
void bookinquiry()
{
int i;
char booknum;
printf("请输入要查询的书号:");
scanf("%s",booknum);
for(i=0;i<5;i++)
if(strcmp(booknum,book.book_num)==0)
{
printf("编号书名借出日期状态\n");
printf("%s %s",book.book_num,book.book_name);
printf("%4d年%2d月%2d日",book.date.year,book.date.month,book.date.day);
if(book.flag==1)
printf("未借出!\n");
else
printf("已借出!\n");
}
printf("1.确认并返回菜单 2.确认信息并退出\n");
scanf("%d",&i);
if(i==1)
menu();
else
exit(0);
}
void bookupdate()
{
printf("这是新书上架和旧书下架的函数\n");
}
void readerinquiry()
{
int i;
char studentname;
printf("请输入要查询的读者");
scanf("%s",studentname);
for(i=0;i<5;i++)
if(strcmp(studentname,card.student_name)==0)
{
printf("借书证号姓名书名借出日期\n");
printf("%s %s %s",card.card_num,card.student_name,book.book_name);
printf("%4d年%2d月%2d日\n",book.date.year,book.date.month,book.date.day);
}
printf("1.确认并返回菜单 2.确认信息并退出\n");
scanf("%d",&i);
if(i==1)menu();
else exit(0);
}
void readerupdate()
{
printf("这是添加与删除读者的函数\n");
}
void reborrow()
{
int i;
char booknum;
printf("请输入要续借的书号");
scanf("%s",booknum);
for(i=0;i<5;i++)
if(strcmp(booknum,book.book_num)==0)
{
printf("编号书名借出日期状态\n");
printf("%s %s",book.book_num,book.book_name);
printf("%4d年%2d月%2d日",book.date.year,book.date.month,book.date.day);
if(book.flag==1)
printf("不能续借!\n");
else
printf("可以续借!\n");
}
printf("1.确认续借 2.取消续借");
scanf("%d",&i);
if(i==1)
{
book.flag=0;
printf("续借日期填写:(请按年/月/日的顺序,如2019/9/8)\n");
scanf("%d/%d/%d",&book.date.year,&book.date.month,&book.date.day);
}
else
printf("1.确认并返回菜单 2.确认信息并退出\n");
scanf("%d",&i);
if(i==1)menu();
else exit(0);
}
void menu()
{
int n;
printf("~~~欢迎使用本校图书管理系统~~~\n");
printf("*******************************\n");
printf("1.借书\n");
printf("2.还书\n");
printf("3.图书查询\n");
printf("4.新书上架和旧书下架\n");
printf("5.读者查询\n");
printf("6.添加与删除读者\n");
printf("7.续借\n");
printf("8.退出\n");
printf("请选择以上选项:\n");
printf("*******************************\n");
scanf("%d",&n);
switch(n)
{
case 1:borrowbook();break;
case 2:returnbook();break;
case 3:bookinquiry();break;
case 4:bookupdate();break;
case 5:readerinquiry();break;
case 6:readerupdate();break;
case 7:reborrow();break;
case 8:exit(0);break;
default:printf("输入错误,退出\n");exit(0);break;
}
}
void main()
{
int i;
char num;
printf("请输入你的卡号");
scanf("%s",num);
for(i=0;i<5;i++)
if(strcmp(num,card.card_num)==0)
break;
if(i>=5)
{
printf("卡号不存在!");
exit(0);
}
else
menu();
}
我的天,用链表写啊
页:
[1]