zoukankan      html  css  js  c++  java
  • 实验二 单链表的实现

    假设有结构如下:

    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);*/
    }


  • 相关阅读:
    C/C++一些库函数的实现
    约瑟夫环问题(Josephus)
    union关键字及大小端模式
    指针数组和数组指针
    巧用位运算
    C/C++生成可执行文件过程
    C语言+Modbus+NXP整体规划
    bug和待完善
    python学习第二课
    python学习第一课
  • 原文地址:https://www.cnblogs.com/accept/p/8175856.html
Copyright © 2011-2022 走看看