#define _CRT_SECURE_NO_WARNINGS_
#include<stdio.h>
#include<math.h>
#define ElemType int
#define temp_ElemType d
#define ERROR -1
typedef struct po {
ElemType data;
Node *next;
}Node ;
Node* Init_List() {
Node* p = (Node*)malloc(sizeof(Node));
p->next = NULL;
scanf("%temp_ElemType", &p->data);
return p;
}
void Destory_List(Node* p) {
int k = 0;
Node* temp = p;
for (k = 1; temp->next; k++) temp = temp->next;
while (k > 1) {
temp = p;
while (temp->next) temp = temp->next;
free(temp);
k--;
}
free(p);
}
Node* Clear_List(Node* p) {
int k = 0;
Node* temp = p;
for (k = 1; temp->next; k++) temp = temp->next;
while (k > 1) {
temp = p;
while (temp->next) temp = temp->next;
free(temp);
k--;
}
p->next = NULL;
}
int List_empty(Node* p) {
if (p->next) return 0;
else return 1;
}
Node* Insert_Node(Node* p, int i) {
Node* q = (Node*)malloc(sizeof(Node));
scanf("%temp_ElemType", q->data);
Node* temp = p;
int k = 0;
for (k = 0; k < i - 1 && temp->next != NULL; k++) temp = temp->next;
if (k != i - 2) exit(ERROR);
else {
q->next = temp->next;
temp->next = q;
return p;
}
}
Node* Delete_Node(Node* p, int i) {
Node* temp = p;
int k = 0;
for (k = 0; k < i - 1 && temp->next != NULL; k++) temp = temp->next;
if (k != i - 2) exit(ERROR);
else {
temp->next = temp->next->next;
free(temp->next);
return p;
}
}
ElemType* Get_Elem(Node* p, int i, ElemType* e) {
Node* temp = p;
int k = 0;
for (k = 0; k < i - 1 && temp->next != NULL; k++) temp = temp->next;
if (k != i - 2) exit(ERROR);
else {
*e = temp->next->data;
return e;
}
}
int main() {
printf("-1");
return 0;
}
|