# 程序设计能力实训

1086. 单向链表中的节点删除

### 样例

Input
3
1
1
1
2
3 4
4
5
12 12 18 12 12
12

Output
case #0:

case #1:
3
case #2:
18


### 提示

// ********** Specification of struct Node **********
typedef struct Node
{ int value;
struct Node *next;
}NODE;
/*/////////////////////////////////////////////////////*/
NODE *EraseNodes(NODE *h,int v)
{ //TODO: your definition
}
/*/////////////////////////////////////////////////////*/
/***************************************************************/
/*                                                             */
/*  DON'T MODIFY below code anyway!                             */
/*                                                             */
/***************************************************************/
#include <stdio.h>
#include <malloc.h>
//********** Specification of EraseNodes(head,v) **********
NODE *EraseNodes(NODE *h,int v);
/* PreCondition:
h is a head pointer of a linked-list, v is an integer
PostCondition:
return the head pointer of a linked-list that has not v in its nodes
*/
void solve()
{ int i,n,v; NODE* head=0,*p,*tail;
scanf("%d",&n);
for (i=0;i<n;i++)
{ p=(NODE*)malloc(sizeof(NODE));
scanf("%d",&p->value); p->next=0;
if (head==0) head=tail=p; else { tail->next=p; tail=p; }
}
scanf("%d",&v);
//********** EraseNodes is called here **********
head=EraseNodes(head,v);
//****************************************
while (head)
{ p=head; head=head->next;
printf("%d",p->value);
if (head) printf(" ");
free(p);
}
printf("\\n");
}
int main()
{  int i,t;
scanf("%d\\n",&t);
for (i=0;i<t;i++)
{ printf("case #%d:\\n",i);
solve();
}
return 0;
}