图书管理系统(数组)

这是一个初学者编写的图书管理系统,采用结构体数组实现,展示了作者在编程学习过程中的初步尝试。
摘要由CSDN通过智能技术生成

自己第一个写的图书管理系统,运用的是结构体数组,很稚嫩,算是成长的一小步


#include<stdio.h>

#include<string.h>
#include<io.h>
#include<windows.h>
#define N1 20
#define N2 20
#define N sizeof(struct club)
#define M sizeof(struct book)
struct book{
char book_name[30];
int bianhao;
double price;
char author[20];
char state[20];
char name[20];
char sex[10];
int xuehao;
};
struct club
{
char name[20];
char sex[10];
int xuehao;
char mima[20];
char borrow[30];
};


struct book book[N1];
struct club club[N2];
void background1();
void choice1(struct club club[],int n);
void fanhui1(struct club club[],int n);
void denglu(struct club club[],int n);
void zhuce(struct club club[],int n);
void Insert_Club(struct club club[],int n);
void Lent_Book(int bianhao,int xuehao,struct book book[],int m,struct club club[],int n);
void Search_Book_bianhao(struct book book[],int m,int bianhao);
void Search_Book_name(struct book book[],int m,char b_name[]);
void back(struct book book[],int m,struct club club[],int n,int bianhao,int xuehao);
void Search_Book_price(struct book book[],int m,double price_h,double price_l);
void Insert_Book(struct book book[],int m);
void Delete_Book(struct book book[],int m,int bianhao);
void Delete_Club(struct club club[],int n,int xuehao);
void Print_Book(struct book book[],int m);
void Print_Club(struct club club[],int n);
void Search_Club_xuehao(struct club club[],int n,int xuehao);
void Search_Club_name(struct club club[],int n,char c_name[]);




int main(void)
{
int i,j,n=N1,m=N2;
FILE *p,*p1;
int choice;
int bianhao,xuehao;
int f;
char b_name[20],c_name[20];
double price,price_h,price_l;
int k,l;
char book_name[30],name[20],author[20],sex[10];


p=fopen("会员.txt","r");
fread(club,N,N1,p);
fclose(p);
background1();
choice1(club,n);
p=fopen("会员.txt","wt+");
fwrite(club,N,N1,p);
fclose(p);
p1=fopen("图书.txt","r");
fread(book,M,N2,p1);
fclose(p1);
do{ 
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");
printf("\n");
printf("\t\t\t[1]:借书办理\t");printf(" [6]:还书办理\n");
printf("\t\t\t[2]:查询图书\t");printf(" [7]:查询会员\n");
printf("\t\t\t[3]:添加图书\t");printf(" [8]:添加会员\n");
printf("\t\t\t[4]:删除图书\t");printf(" [9]:删除会员\n");
printf("\t\t\t[5]:遍历图书\t");printf("[10]:遍历会员\n\n");
printf("\t\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n\n");
printf("\t\t\t0:退出\n\n");
printf("请选择<0~10>:");
        scanf("%d",&choice);
switch(choice){
case 1:
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");
printf("输入所借图书编号:\n");
scanf("%d",&bianhao);
printf("输入借书人的学号:\n");
scanf("%d",&xuehao);
Lent_Book(bianhao,xuehao,book,m,club,n);
Search_Book_bianhao(book,m,bianhao);
break;
case 2:
system("cls");
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");
printf("1.按编号查询\n\n");
printf("2.按名称查询\n\n");
printf("3.按价格区间查询\n\n");
printf("0.返回主菜单\n\n");
printf("请选择:");
scanf("%d",&f);
if(f==1){
printf("请输入查询图书编号:");
   scanf("%d",&bianhao);
   printf("相关信息如下:\n\n");
   Search_Book_bianhao(book,m,bianhao);
   break;
}
else if(f==2){
printf("请输入查询图书名称:");
   gets(b_name);
   getchar();
   printf("相关信息如下:\n\n");
   Search_Book_name(book,m,b_name);
   break;
}
else if(f==3){
printf("请输入最高价格:");
scanf("%lf",&price_h);
printf("请输入最低价格:");
scanf("%lf",&price_l);
printf("相关信息如下:\n\n");
Search_Book_price(book,m,price_h,price_l);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值