#define _CRT_SECURE_NO_DEPRECATE
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#define N sizeof(struct book)
#define PT "%-5d %10s %6s %6s %6s %3d %5d %-15s\n",p->num,p->name,p->here,p->author,p->pub,p->count,p->price,p->date
struct book /*图书信息*/
{
int num; /*书号*/
char name[10]; /*书名*/
char here[10]; /*所在书库*/
char author[15]; /*作者*/
char pub[20]; /*出版社*/
int count; /*数量*/
int price; /*价格*/
char date[20]; /*购买日期*/
struct book *next;
};
/*输出模块*/
void print(struct book *p0)
{
struct book *p;
p=p0->next;
printf("\n\n\t\t^^^^^^^^^^^^^^图书信息表^^^^^^^^^^^^^^");
printf("\n\n图书编号---图书名称---所在书库----作者----出版社---数量---价格---购买日期\n");
while(p!=NULL)
{
printf(PT);
p=p->next;
}
getch();
}
/*输入模块*/
struct book *creat()
{
struct book *head,*p1,*p2;
int i=0;
head=p2=(struct book *)malloc(N);
head->next=NULL;
printf("\n\n\t\t录入图书信息");
printf("\n\t---------------------------------------");
while(1)
{ p1=(struct book *)malloc(N);
printf("\n 请输入图书编号(书号为0结束): ");
scanf("%d",&p1->num);
if(p1->num!=0)
{
printf("\n\n书名 所在书库 作者 出版社 图书数量 价格 购买日期\n");
scanf("%s%s%s%s%d%d%s",p1->name,p1->here,p1->author,p1->pub,&p1->count,&p1->price,p1->date);
p2->next=p1;
p2=p1;
i++;
}
else
break;
}
p2->next=NULL;
free(p1);
printf("\n\t\t----------------------------------------");