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


  • 相关阅读:
    检测后缀表达式的合法性
    对表达式进行空白符预处理
    字符串替换
    中缀表达式的计算
    Linux shell编程
    Linux常用shell
    [转载]shell脚本编写规范
    [转载]Linux文件类型
    Linux的进程
    Linux进入命令行模式
  • 原文地址:https://www.cnblogs.com/accept/p/8175856.html
Copyright © 2011-2022 走看看