2012.1.3 链表
typedef struct node
{
int data1;
char data2[10];
node *next;
}*ptrN;
ptrN accessNode(const ptrN head,int n)
{
ptrN tmpNode;
if (head == 0)
{
return 0;
}
else
{
tmpNode = head;
}
for (int i = 0;i < n-1; i++)
{
if (tmpNode->next == 0)
{
return 0;
}
tmpNode = tmpNode->next;
}
return tmpNode;
}
ptrN accessTrail(const ptrN head)
{
ptrN tmpNode;
if (head == 0)
{
return 0;
}
else
{
tmpNode = head;
}
while (tmpNode->next)
{
tmpNode = tmpNode->next;
}
return tmpNode;
}
tmpNode->data = 10;
或者(*tmpNode).data = 10;