PAT 数据结构
PAT甲级题目整理
链表
- 做题时一般使用静态链表
struct Node {
int data;
Node* next;
};
//静态链表
struct Node {
int data;
int next;
} node[MAX];
Node* create(int arr[]) {
Node* p, head, pre;
head = new Node;
head->next = NULL;
pre = head;
for (int i = 0; i < n; ++i) {
p = new Node;
p->data = arr[i];
p->next = NULL;
pre->next = p;
pre = p;
}
return head;
}