【发布时间】:2015-02-20 22:41:10
【问题描述】:
我正在尝试获取链表的第一个元素并将其移动到最后一个位置。我是用这段代码做到的:
pend=pstart;
while(pend->next != NULL) // go to the last element
{
pend = pend->next;
}
pend->next=pstart;
pend=pstart;
pstart=pstart->next;
pend->next=NULL;
但似乎我可能遗漏了一些东西,因为我没有得到我想要的结果。所以,我的问题是:这段代码正确吗?如果没有,请帮我修复它。谢谢。
【问题讨论】:
-
您的代码在我看来是正确的。您能否详细说明“我没有得到我想要的结果”?
-
另外,需要更多的上下文来理解这个问题,最好是Minimal, Complete, and Verifiable example。
-
对我来说看起来是正确的。
标签: c list linked-list