将单链表反转,但不能用堆栈~谁来说说思路

iacpdj 2006-09-05 05:34:14
不能用堆栈,将将单链表反转(converse),来说说思路
...全文
148 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zwq80877 2006-09-05
  • 打赏
  • 举报
回复
Knight94(愚翁) ( ) 信誉:110 Blog 2006-9-5 17:57:01 得分: 0



Node nReverse, nCurrent;
nReverse = null;
nCurrent = yourList;
while( yourList.Next != null )
{
Node itm = nCurrent;
nCurrent = nCurrent.Next;
itm.Next = nReverse;
nReverse = itm;
}
return nReverse;



正解
greennetboy 2006-09-05
  • 打赏
  • 举报
回复
string[] ss = new string[] { "a", "v" ,"d"};
Array.Reverse(ss);
foreach (string s in ss)
{
MessageBox.Show(s);
}
iacpdj 2006-09-05
  • 打赏
  • 举报
回复
多谢提示
看看,是否可行
Knight94 2006-09-05
  • 打赏
  • 举报
回复
以上只是给个思路,至于数据结构之类没有加上说明。
Knight94 2006-09-05
  • 打赏
  • 举报
回复
Node nReverse, nCurrent;
nReverse = null;
nCurrent = yourList;
while( yourList.Next != null )
{
Node itm = nCurrent;
nCurrent = nCurrent.Next;
itm.Next = nReverse;
nReverse = itm;
}
return nReverse;
Knight94 2006-09-05
  • 打赏
  • 举报
回复
to 不能用堆栈,将将单链表反转(converse),来说说思路

做一次循环就行了

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧