zoukankan      html  css  js  c++  java
  • 数据结构实验

    实验1:

     答题:

    #include"sqlist.cpp"
    void main()
    {
        SqList *L;
        ElemType e;
        InitList(L);
        ListInsert(L,1,'a');
        ListInsert(L,2,'b');
        ListInsert(L,3,'c');
        ListInsert(L,4,'d');
        ListInsert(L,5,'e');
        printf("顺序表为:");DispList(L);
        printf("顺序表长度为:%d
    ",ListLength(L));
        ListEmpty(L);
        if(ListEmpty(L))
            printf("顺序表为空
    ");
        else
            printf("顺序表为非空
    ");
        GetElem(L,3,e);
        printf("顺序表的第3个元素为:%c
    ",e);
        printf("元素a的位置为:%d
    ",LocateElem(L,'a'));
        ListInsert(L,4,'f');
        printf("插入第4个元素后顺序表为:");DispList(L);
        ListDelete(L,3,e);
        printf("删除第三个元素后顺序表为:");DispList(L);
        DestroyList(L);
    
    }

    运行结果:

    参考答案:

    实验2:

     

     答题:

    #include"linklist.cpp"
    void main()
    {
        LinkNode *L;
        ElemType e;
        InitList(L);
        ListInsert(L,1,'a');
        ListInsert(L,2,'b');
        ListInsert(L,3,'c');
        ListInsert(L,4,'d');
        ListInsert(L,5,'e');
        printf("单链表为:");
        DispList(L);
        printf("单链表长度为:%d
    ",ListLength(L));
        ListEmpty(L);
        if(ListEmpty(L))
            printf("单链表为空
    ");
        else
            printf("单链表为非空
    ");
        GetElem(L,3,e);
        printf("单链表的第3个元素为:%c
    ",e);
        printf("元素a的位置为:%d
    ",LocateElem(L,'a'));
        ListInsert(L,4,'f');
        printf("在第4个位置上插入f后单链表为:");
        DispList(L);
        ListDelete(L,3,e);
        printf("删除第3个元素后单链表为:");
        DispList(L);
        DestroyList(L);
    }

    运行结果:

    参考答案:

  • 相关阅读:
    tp5 select回显
    toFixed
    用js来实现银行家算法
    js 日期证有效性验的通用方法
    js获取或判断任意数据类类型的通用方法(getDataType)和将NodeList转为数组(NodeListToArray)
    js实现jquery函数animate动画效果
    js原生实现 无缝滚动图片
    scrollTop实现图像循环滚动(实例1)
    commonCookie.js
    delphi XE3解析JSON数据
  • 原文地址:https://www.cnblogs.com/nicaihui/p/12485542.html
Copyright © 2011-2022 走看看