实验二 单链表的实现

假设有结构如下:

struct book { char *ISBN//书号 char *name;//书名 char *author;//作者 char *publisher;//出版社 double price;//定价 }

完成如下功能:

1、输入十本书的信息,并按行显示输出; 2、插入一本书的信息,并显示输出; 3、删除一本书并显示输出; 4、按书号查询,如找到,显示该书的信息,否则显示“没找到!”。 *5、按书号排序,并显示排序后的信息。 6、用静态链表完成上述的功能。


#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
struct book
{
char *ISBN;//书号
char *name;//书名
char *author;//作者
char *publisher;//出版社
double price;//定价
};
struct book *create();
void list();
int main()
{
struct book *p1,*p2,*head;
p1=p2=(struct book*)malloc(sizeof(struct book));
scanf("%s %s %s %s %d",p->ISBN,p->name,p->author,p->publisher,&p->price);
for(int i=0;i<10;i++)
{
p=(struct book*)malloc(sizeof(struct book));
scanf("%s %s %s %s %d",p->ISBN,p->name,p->author,p->publisher,&p->price);
printf("%s %s %s %s %d",p->ISBN,p->name,p->author,p->publisher,p->price);
}

/*for(int i=0;i<10;i++)
printf("%s %s %s %s %d",p->ISBN,p->name,p->author,p->publisher,p->price);*/
}


原文地址:https://www.cnblogs.com/accept/p/8175856.html