You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
struct node {
|
|
|
|
|
int data;
|
|
|
|
|
struct node *next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int main (){
|
|
|
|
|
struct node *head, *p, *q, *t;
|
|
|
|
|
int a,n;
|
|
|
|
|
head=NULL;
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
for(int i = 1;i <= n; i++){
|
|
|
|
|
scanf("%d",&a);
|
|
|
|
|
p=(struct node*)malloc(sizeof(struct node));
|
|
|
|
|
p->data=a;
|
|
|
|
|
p->next=NULL;
|
|
|
|
|
if(head==NULL)
|
|
|
|
|
head=p;
|
|
|
|
|
else
|
|
|
|
|
q->next=p;
|
|
|
|
|
q=p;
|
|
|
|
|
}
|
|
|
|
|
scanf("%d",&a);
|
|
|
|
|
t=head;
|
|
|
|
|
while(t!=NULL) {
|
|
|
|
|
if(t->next==NULL||t->next->data>a) { //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD>β<EFBFBD><CEB2><EFBFBD>ߵ<EFBFBD>ǰ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>aʱ<61><CAB1><EFBFBD><EFBFBD>a<EFBFBD><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
p=(struct node *)malloc(sizeof(struct node)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ڵ<EFBFBD>p<EFBFBD><70><EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
p->data=a;
|
|
|
|
|
p->next=t->next; //<2F><>ʱ<EFBFBD>ڵ<EFBFBD><DAB5>뵱ǰ<EBB5B1>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
t->next=p; //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>β<EFBFBD><CEB2>
|
|
|
|
|
break; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3>˳<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
t=t->next;
|
|
|
|
|
}
|
|
|
|
|
t=head;
|
|
|
|
|
while(t!=NULL) {
|
|
|
|
|
printf("%d ",t->data);
|
|
|
|
|
t=t->next;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|