删除带头结点的非空单链表中值相同的多余结点

结构体为:

  typedef struct LNode{
  	int data;
  	struct LNode *next;
  }LNode,*LinkList;

算法段:

void Delete(LinkList &L)
  {
  	LNode *p = L->next;
  	LNode *pre;
	LNode *q;
	LNode *t;
	while(p->next != NULL)
	{
		pre = p;
		q = pre->next;
		while(q != NULL)
		{
			if(p->data == q->data)
			{
				t = q;
				pre->next = q->next;
				q = pre->next;
				delete t;
			}else{
				q = q->next;
				pre = pre->next;
			}
		}
		p = p->next;
	}
  	
   } 
上一篇:Android:进度条加载


下一篇:使用AsyncTask实现android后台耗时程序的ProgressDialog提示Demo