版权声明:本文为博主原创文章,转载需注明出处。 https://blog.csdn.net/zz_Caleb/article/details/83277513
#include<cstdio>
#include<malloc.h>
typedef struct table{
int t;
table *next;
}node,*List;
int main()
{
freopen("file.txt","r",stdin);
int mink,maxk,n;
scanf("%d%d%d",&mink,&maxk,&n);
List head=(List)malloc(sizeof(node));
List tail=head;
for(int i=0;i<n;i++){
List s=(List)malloc(sizeof(node));
int a;
scanf("%d",&a);
s->t=a;
tail->next=s;
s->next=NULL;
tail=s;
}
List h=head;
for(int i=0;i<n;i++){
if(h->next->t>mink&&h->next->t<maxk){
List q=h->next;
h->next=q->next;
free(q);
}
else h=h->next;
}
h=head->next;
while(h){
printf("%d\n",h->t);
h=h->next; //printf("OK");
}
}