写的双向链表RE了,不知道肿么了,只好随手改了一个头插
#include<cstdio>
#include<cstring>
#include<cstdlib>
typedef struct node
{
int num;
struct node *next;
//struct node *pre;
}SqList;
SqList *creat()
{
SqList *p1,*p2,*temp;
p1=(SqList *)malloc(sizeof(SqList));
scanf("%d",&p1->num);
// p2->next=p1;
p2=NULL;
p1->next=p2;
p2=p1;
//p2->pre=NULL;
p1=(SqList *)malloc(sizeof(SqList));
while(scanf("%d",&p1->num) && p1->num != -1)
{
// temp=p2;
p1->next=p2;
p2=p1;
p1=(SqList *)malloc(sizeof(SqList));
}
return p2;
}
int main()
{
SqList *List;
List = creat();
while(List != NULL)
{
printf("%d\n",List->num);
List=List->next;
}
return 0;
}