#include<stdio.h>
#include<iostream>
#define OK 1
#define ERROR 0
typedef int Elemtype;
typedef int Status;
static int length = 0;
typedef struct ListNode {
Elemtype data;
struct ListNOde* next;
}Node,*Pnode;
Status build_ListNode(Pnode& head, int circle) {
Pnode p;
for (int i = 0; i < circle; i++) {
if (head == '\0') {
if (!(Pnode)malloc(sizeof(struct ListNode))) {
printf("第%d個節點創建失敗\n", i + 1);
return ERROR;
}
else
{
head = (Pnode)malloc(sizeof(struct ListNode));
p = head;
p->next = '\0';
length++;
scanf("%d", &p->data);
}
}
else {
if (!(Pnode)malloc(sizeof(struct ListNode))) {
printf("第%d個節點創建失敗\n", i + 1);
return ERROR;
}
else {
if (i >= 2) {
p = p->next;
}
Pnode r = (Pnode)malloc(sizeof(struct ListNode));
p->next = r;
r->next = '\0';
length++;
scanf("%d", &r->data);
}
}
}
return OK;
}
Status insert_ListNode(Pnode& head, int pos, Elemtype value) {
if (pos<0 || pos>length) {
printf("插入位置不合法\n");
return ERROR;
}
else {
Pnode r, p;
p = head;
for (int i = 0; i < pos - 1; i++) {
p = p->next;
}
r = (Pnode)malloc(sizeof(struct ListNode));
if (pos == 0) {
r->next = p;
head = r;
}
else {
r->next = p->next;
p->next = r;
r->data = value;
}
return OK;
}
}
void fuction_Selection() {
Pnode head;
build_ListNode(head, 10);
insert_ListNode(head, 5, 10);
}
int main() {
fuction_Selection();
return 0;
}

為什會有這樣的錯誤求大神解釋下
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/130401.html
標籤:數據結構與算法
