【DS】2.1

线性表:
c++
各种基础操作里面,有&没&避免错的代码额~

#include <stdio.h>
void test(int &x){//没有&就没有带回主函数 
    x=1024;
    printf("in=%d\n",x); 
}
int main(){
    int x=1;
    printf("%d\n",x);
    test(x);
    printf("%d\n",x);
}

 

 

 注意代码一般是int 0;

 

  • 顺序表

动态申请~ 时间开销好大

void InitList(SeqList &L){
    L.data=(int *)malloc(InitList*sizeof(int));
    L.length=0;
    L.MaxSize=InitList;
}
int main(){
    SeqList L; 
    InitList(L);//初始化
    //插入数据
    IncreaseSize(L,5);
    return 0; 
} 

 

 

 

 

 

插入数据

 

 删除:

 

 

 

查找
按位查找

 

按值查找

 

 

 

 总结- - 是真的困

 

posted @ 2022-07-29 23:55  Tityaaaa  阅读(21)  评论(0编辑  收藏  举报