




学习不可少
struct student {int num; int score; struct student *next;}; struct student *del(struct student *head,int num) {struct student *p1,*p2; if(head==NULL) {printf("\nlist null! \n"); } p1=head; while(num!=p1->num&&p1->next!=NULL) {p2=p1; p1=p1->next;} if(num==p1->num) {if(p1==head) head=p1->next; else p2->next=p1->next; printf("delete :%d\n",num); n=n-1;} else printf("%d not been found!\n",num); return(head);}
struct student *insert(struct student *head,struct student *stud) {struct student *p0,*p1,*p2;
p1=head; p0=stud; if(head==NULL) {head=p0;p0->next=NULL;} else {while((p0->num>p1->num)&&(p1->next!=NULL)) {p2=p1;p1=p1->next;} if(p0->num<=p1->num) {if(head==p1) head=p0; else p2->next=p0; p0->next=p1; } else { p1->next=p0; p0->next=NULL; } }
return(head); }
struct student
{int num;
int score;
struct student *next;};
struct student *del(struct student *head,int num)
{struct student *p1,*p2;
if(head==NULL)
{printf("\nlist null! \n");
} p1=head;
while(num!=p1->num&&p1->next!=NULL)
{p2=p1;
p1=p1->next;}
if(num==p1->num)
{if(p1==head)
head=p1->next;
else
p2->next=p1->next;
printf("delete :%d\n",num);
n=n-1;}
else
printf("%d not been found!\n",num);
return(head);}
struct student *insert(struct student *head,struct student *stud)
{struct student *p0,*p1,*p2;
p1=head;
p0=stud;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{while((p0->num>p1->num)&&(p1->next!=NULL))
{p2=p1;p1=p1->next;}
if(p0->num<=p1->num)
{if(head==p1)
head=p0;
else
p2->next=p0;
p0->next=p1;
}
else
{ p1->next=p0;
p0->next=NULL; }
}
return(head);
}
我这样的问题发出好多次了
不过这好象是数据结构的题
怎么来这了
struct student
{int num;
int score;
struct student *next;};
struct student *del(struct student *head,int num)
{struct student *p1,*p2;
if(head==NULL)
{printf("\nlist null! \n");
} p1=head;
while(num!=p1->num&&p1->next!=NULL)
{p2=p1;
p1=p1->next;}
if(num==p1->num)
{if(p1==head)
head=p1->next;
else
p2->next=p1->next;
printf("delete :%d\n",num);
n=n-1;}
else
printf("%d not been found!\n",num);
return(head);}
struct student *insert(struct student *head,struct student *stud)
{struct student *p0,*p1,*p2;
p1=head;
p0=stud;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{while((p0->num>p1->num)&&(p1->next!=NULL))
{p2=p1;p1=p1->next;}
if(p0->num<=p1->num)
{if(head==p1)
head=p0;
else
p2->next=p0;
p0->next=p1;
}
else
{ p1->next=p0;
p0->next=NULL; }
}
return(head);
}
或者
void insert_pos_sequence_list(sequence_list *slt,int position,datatype x)
{ int i;
if(slt->size==maxsize)
{printf("\n顺序表是满的!没法插入!");exit(1);}
if(position<0||position>slt->size)
{printf("\n指定的插入位置不存在!");exit(1);}
for(i=slt->size;i>position;i--) slt->a[i]=slt->a[i-1];
slt->a[position]=x;
slt->size++;
}