已加_CRT_SECURE_NO_WARNINGS
假期预习想自己试着写一下链表 单链双链都没问题 到循环链这里就如下(实力不济求包含)
#include<stdio.h>
#include<stdlib.h>
typedef struct{
struct Struction* next;
struct Struction* prep;
int value;
}Struction;
typedef struct point{
Struction* head;
Struction* circle;
}Point;
void Print(Point* List,int n);
int Length(Point* List);
void Insert(Point* List);
int main()
//循环链表 (无头结点)
{
int n;
scanf("%d",&n);
Point List;
List.head=NULL;
List.circle=NULL;
int i=0;
for(i;i<n;i++){
Struction* p=(Struction*)malloc(sizeof(Struction));
if(List.head==NULL){
List.head=p;
List.circle=p;
p->next=NULL;
p->prep=NULL;
}else{
List.circle->next=p;
p->prep=List.circle;
List.circle=p;
p->next=List.head;
}
scanf("%d",&(p->value));
}
Print(&List,n);
}
int Length(Point* List)
{
Struction* plist=List->head;
int len=0;
for(len,plist;plist!=List->circle;plist=plist->next){
len++;
}
return len;
}
void Insert(Point* List)
{
int num;
scanf("%d",&num);
int len=Length(List);
if(num>=0&&num<=len){
Struction* plist;
Struction* p=(Struction*)malloc(sizeof(Struction));
if(num==0){
plist=List->head;
plist->prep=p;
p->next=plist;
p->prep=NULL;
List->head=p;
List->circle->next=p;
}else if(num==len){
plist=List->circle;
plist->next=p;
p->prep=plist;
p->next=List->head;
p=List->circle;
}else{
plist=List->head;
int i=1;
if(num<=len/2){
for(i,plist;i<=num-1;i++,plist=plist->next);
p->next=plist->next;
plist->next=p;
_**p->next->prep=p;**_
p->prep=plist;
}else{
for(i,plist;i<=len-num;plist=plist->prep);
p->prep=plist->prep;
plist->prep=p;
_**p->prep->next=p;**_
p->next=plist;
}
}
}else{
printf("Wrong input.\n");
}
}
void Print(Point* List,int n)
{
Struction* plist=List->head;
int i=0;
for(plist,i;i<n;plist=plist->next,i++){
printf("%d ",plist->value);
}
printf("\n");
}
报错在Insert函数中的斜体粗体部分(78、84行),报错内容如标题
不清楚原因