求大神帮我看看如何
#include <stdio.h>#include <process.h>
#include <malloc.h>
#include <conio.h>
typedef int DATA;
struct SNode
{
DATA data;
struct SNode*pNext;
}*g_pHead=NULL;
void AddTail(DATA d)
{
struct SNode *p=g_pHead;
struct SNode *pNew=(struct SNode*)malloc(sizeof(struct SNode));
pNew->data=d;
pNew->pNext=NULL;
if(!p)
{
g_pHead=pNew;
return;
}
while(p->pNext)
p=p->pNext;
p->pNext=pNew;
}
void AddHead(DATA d)
{
struct SNode *pNew=(struct SNode*)malloc(sizeof(struct SNode));
pNew->data=d;
pNew->pNext=g_pHead;
g_pHead=pNew;
}
void Print()
{
struct SNode *p=g_pHead,*p1;
while(p)
{
p->pNext=p->pNext;
free(p);
break;
}
p1=p;
p=p->pNext;
}
void Modify(int nDld,int nNew)
{
struct SNode *p=g_pHead;
while(p)
{
if(p->data==nDld)
p->data=nNew;
p=p->pNext;
}
}
void Remove(DATA d)
{
struct SNode *p=g_pHead,*p1;
if(p->data==d)
{
g_pHead=p->pNext;
free(p);
return;
}
while(p)
{
if(p->data==d)
{
p1->pNext=p->pNext;
free(p);
break;
}
p1=p;
p=p->pNext;
}
}
int main(int argc,char *argv[])
{
AddTail(881);
AddTail(888);
AddTail(666);
AddTail(225);
AddTail(999);
Modify(225,688);
Remove(666);
Print();
return 0;
}