//数组模拟链表比较快
//静态链表
#include<iostream>
using namespace std;
const int N = 100001;
// head 表示头结点的下标
// e[N] 表示节点i的值
// ne[N] 表示节点i的next指针是多少
// idx存储当前已经用到了哪个点
int head, e[N], ne[N], idx;
void init()
{
head = -1;
idx = 0;
}
//将x插入到头节点
void add_to_head(int x)
{
e[idx] = x;
ne[idx] = head;
head = idx;
idx++;
}
//k为下标
void add(int k, int x) {
e[idx] = x;
ne[idx] = ne[k];
ne[k] = idx;
idx++;
}
//将下标为k的点的后面一个点删除
void remove(int k) {
ne[k] = ne[ne[k]];
}
int main()
{
system("pause");
return 0;
}
06-18
06-18
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交