zoukankan      html  css  js  c++  java
  • 未完

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    #define LIST_INIT_SIZE 100
    #define LIST_INCREMENT 10
    int *p, *q;
    typedef struct{
        int *elem;      //基地址类型怎么写也就是这个线性表中存储的数据的类型
        int length;
        int listsize;
    }SqList;
    bool InitList_Sq(SqList &L)//创建线性表的时候函数返回类型可以表示这个线性表是否创建成功
    {
        L.elem = (int *)malloc(LIST_INIT_SIZE*sizeof(int));
        if(!l.elem)exit(OVERFLOW);//存储分配失败,但OVERFLOW?????是什么????????????????????????????
        L.length = 0;
        L.listsize = LIST_INIT_SIZE;
        return 1;
    }
    bool ListInsert_Sq(SqList &L, int i, int e){
        if(i < 1 || i > L.length + 1) return 0; // 等于L.length+1不是也应该报错吗??????????????
        if(L.length >= L.listsize){
            int *newbase = (int *)realloc(L.elem, (L.listsize + LIST_INCREMENT)*sizeof(int));
            if(!newbase) exit(OVERFLOW); //OVERFLOW??????????????????
            L.elem = newbase;
            L.listsize += LIST_INCREMENT;
        }
        q = &(L.elem[i-1]);
        for(p = &(L.elem[L.length-1]); p >= q; --p) *p+1 = *p;
        *q = e;
        ++L.length;
        return 1;
    }
    bool ListDelete_Sq(SqList &L, int i, int &e)
    {
        if((i < 1)||(i > L.length)) return 0;
        p = &(L.elem[i-1]);
    }
    void main()
    {}

     冒泡,快排,归并排序,sort排序,sort(a, a+n),sort(a, a+n, cmp); 二分查找,栈(top指针)(str提供有栈的操作),队列(pre和last指针),链表,

  • 相关阅读:
    第二月 day 2,内置函数
    第二月 day3 闭包,递归
    day4 装饰器
    第二月 day1生成器
    第一个月 总结
    day 16 迭代器
    day 15 编码
    Docker常用命令
    DRF源码刨析
    django中使用qiniu作为第三方存储
  • 原文地址:https://www.cnblogs.com/rain-1/p/4835633.html
Copyright © 2011-2022 走看看