#include <stdio.h>
#include <stdlib.h>
typedef struct LinkNode
{
int data;
struct linknode *prev,*next;
}Node,*List;
List Createlist(int n)
{
List head=(List)malloc(sizeof(Node));
Node* p;
Node* q;
int a;
p=head;
for(int i=0; i<n; i++)
{
q=(List)malloc(sizeof(Node));
scanf("%d",&a);
p->next=q;
q->prev=p;
q->data=a;
p=q;
}
p->next=NULL;
head=head->next;
head->prev=NULL;
return head;
}
void Delete_x(List L,int n,int x)
{
Node* p=L;
Node* r=L;
Node* q=L;
for(int i=0;i<n;i++)
{
if(L->data==x)
{
r=p->next;
r->prev=NULL;
L=r;
}
else if(p->data==x&&p->next!=NULL)
{
q=p->prev;
r=p->next;
q->next=r;
r->prev=q;
}
if(p->data==x&&p->next==NULL)
{
q=p->prev;
q->next=NULL;
}
p=p->next;
}
while(L)
{
printf("%d ",L->data);
L=L->next;
}
}
int main(void)
{
int n;
scanf("%d",&n);
List L=Createlist(n);
int x;
scanf("%d",&x);
Delete_x(L,n,x);
return 0;
}
main.c: In function 'Createlist': main.c:20:16: warning: assignment from incompatible pointer type [enabled by default] p->next=q; ^ main.c:21:16: warning: assignment from incompatible pointer type [enabled by default] q->prev=p; ^ main.c:28:6: warning: assignment from incompatible pointer type [enabled by default] p=p->next; ^ main.c: In function 'Delete_x': main.c:43:14: warning: assignment from incompatible pointer type [enabled by default] r=p->next; ^ main.c:49:14: warning: assignment from incompatible pointer type [enabled by default] q=p->prev; ^ main.c:50:14: warning: assignment from incompatible pointer type [enabled by default] r=p->next; ^ main.c:51:20: warning: assignment from incompatible pointer type [enabled by default] q->next=r; ^ main.c:52:20: warning: assignment from incompatible pointer type [enabled by default] r->prev=q; ^ main.c:56:14: warning: assignment from incompatible pointer type [enabled by default] q=p->prev; ^ main.c:59:10: warning: assignment from incompatible pointer type [enabled by default] p=p->next; ^ main.c:64:10: warning: assignment from incompatible pointer type [enabled by default] L=L->next; ^
在code:blocks中没有任何错误,在teacher要求的平台上就有这么一大长串的错误,怎么改呀?