📄 图书管理系统(新).cpp
字号:
#include "stdio.h"
#include "stdlib.h"
struct Date
{
int year;
int month;
int day;
};
struct Book
{
int Nub;
char Name[10];
char Pub_Name[10];
struct Date Pub_date;
char state[5];
int Borrow_Nub;
struct Book *next;
};
/*struct Reader
{
struct Card stu;
char Name[10];
char Depart[10];
int Nuber;
};*/
/*struct Card
{
long Nuber;
struct Reader N;
struct Date Push;
};
/*Ruku*/
int Newbook();
void main()
{
int xuanze;
printf("Please input your choose:\n");
scanf("%d",&xuanze);
switch(xuanze)
{
case 1:
printf("Your choose is that to add new bookes for the labrary!\n");
Newbook();
break;
/* case 2:
printf("Your choose is that to return the lended bookes:");
Return();
break;*/
default:
printf("Sorry!Your choose is't exit and you'll be allowed to use the systerm!!\n");
}
}
int Newbook()
{
struct Book *M;
struct Book *head;
FILE *fp;
fp=fopen("图书管理系统文件1.txt","ab+");
while((M=(struct Book *)malloc(sizeof(struct Book)))!=NULL)
{
M->next=NULL;
head=M;
M=M->next;
printf("请输入书的统一编号:(0-1000)\n");
scanf("%d",&M->Nub);
printf("请输入书的名称:\n");
scanf("%s",M->Name);
printf("请输入出版社:\n");
scanf("%s",M->Pub_Name);
printf("请输入出版日期:\n");
scanf("%d%d%d",&M->Pub_date.year,&M->Pub_date.month,&M->Pub_date.day);
if((fp=fopen("图书管理系统文件1.txt","ab+"))==NULL)
printf("Error!Can't open the file\n");
else
fwrite(head,sizeof(struct Book),1,fp);
printf("\n————入库新书资料统计如下————\n");
printf("\n||||统一编号--书名--出版社--出版日期||||\n");
while(!feof(fp))
{
fread(head,sizeof(struct Book),1,fp);
printf("%d, %s, %s, %d.%d.%d\n",M->Nub,M->Name,M->Pub_Name,
M->Pub_date.year,M->Pub_date.month,M->Pub_date.day);
}
fclose(fp);
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -