English 中文(简体)
联系名单——几乎是做的,但有些地方仍然存在次要问题。 所需帮助
原标题:Linked list - Almost done, but still minor problems somewhere. Help needed
  • 时间:2011-02-26 17:13:49
  •  标签:
  • c++
void currentfor() 

{

   if(current == NULL) 

{

      cout << "You don t have any members yet!" << endl;

   }
 else
 {

 if (current->next == NULL)

         cout << "This is the end of the list." << endl;
      else
         current = current->next;
   }

}

void currentbac() 
{

   if (current == first)

      cout << "This is the beginning of the list." << endl;

   else
 {

      list *previous;

      previous = first;

      while (previous->next != current)
 {

         previous = previous->next;

      }

      current = previous;

   }

}

I m ALMOST 在那里,但仍然存在一个问题。

我如何知道我目前的立场是在我改变目前立场的时候? 由于每当我使用这两种移动功能时,似乎就没有工作。 在我行走时,我试图在“目前”的位置上增加一个节点,但总是在一切节点之后加上该项目。

PLUS in my previous code I m not able to change the fact that the "<--current position" is pointing at all the nodes and not at one node.

我要指出一点,更清楚的是,用户知道目前点的人在哪里。

希望者理解。 我只字不提C++,但我的教授希望我自己(无论这意味着什么)学习,我现在试图在网上查阅其如此困难的参考资料,以便获得Im项目的信息。

最佳回答

"I try to add a node at the "current"position when i move but its always adding at the end after all the nodes."

问题在于你添加了条码,而不是你的移动代码。

你没有公布你的补充准则,因此很难说问题是什么。 你们必须把新节之前和之后的节点连接起来,并将其与新的节点连接起来,并且把新节点与两个老节点连接起来——始终牢记要认真处理第一和最后的节点。 你们是否做了这一切?

问题回答

如果你刚才需要一个相关的清单来执行你的项目,那么它就建议使用: 查阅。 。 如果想学习C++,该页上也有一个辅导。

Specify the structure of the node. (I mean the data you are holding in the list node. eg. Int or float or some object). As said by JohnFx best way to traverse backwards is by using a doubly link list. Specify the insertion code you are using and the your node sturture.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签