1. <i id='OnIhM'><tr id='OnIhM'><dt id='OnIhM'><q id='OnIhM'><span id='OnIhM'><b id='OnIhM'><form id='OnIhM'><ins id='OnIhM'></ins><ul id='OnIhM'></ul><sub id='OnIhM'></sub></form><legend id='OnIhM'></legend><bdo id='OnIhM'><pre id='OnIhM'><center id='OnIhM'></center></pre></bdo></b><th id='OnIhM'></th></span></q></dt></tr></i><div id='OnIhM'><tfoot id='OnIhM'></tfoot><dl id='OnIhM'><fieldset id='OnIhM'></fieldset></dl></div>
      <bdo id='OnIhM'></bdo><ul id='OnIhM'></ul>

  2. <small id='OnIhM'></small><noframes id='OnIhM'>

    <tfoot id='OnIhM'></tfoot>

    1. <legend id='OnIhM'><style id='OnIhM'><dir id='OnIhM'><q id='OnIhM'></q></dir></style></legend>

      单链打印 C++

      singly linked chain printing c++(单链打印 C++)
    2. <tfoot id='qWgl2'></tfoot>

        <legend id='qWgl2'><style id='qWgl2'><dir id='qWgl2'><q id='qWgl2'></q></dir></style></legend>
        <i id='qWgl2'><tr id='qWgl2'><dt id='qWgl2'><q id='qWgl2'><span id='qWgl2'><b id='qWgl2'><form id='qWgl2'><ins id='qWgl2'></ins><ul id='qWgl2'></ul><sub id='qWgl2'></sub></form><legend id='qWgl2'></legend><bdo id='qWgl2'><pre id='qWgl2'><center id='qWgl2'></center></pre></bdo></b><th id='qWgl2'></th></span></q></dt></tr></i><div id='qWgl2'><tfoot id='qWgl2'></tfoot><dl id='qWgl2'><fieldset id='qWgl2'></fieldset></dl></div>

        <small id='qWgl2'></small><noframes id='qWgl2'>

              <tbody id='qWgl2'></tbody>
              • <bdo id='qWgl2'></bdo><ul id='qWgl2'></ul>

              • 本文介绍了单链打印 C++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试以 {1,2,3,4,etc} 格式选择我的链.您可以在下面找到包含节点布局的头文件.我只是对如何循环遍历我的列表以打印出 Item 感到困惑.

                I am trying to pick my chain in the format {1,2,3,4,etc}. You can find the header file below which will have the layout of the nodes. I am just confused on how I should go about cycling through my list to print out Item.

                任何指导将不胜感激!

                set.h

                using namespace std;
                
                #include <iostream>
                
                class Set
                {
                  private:
                
                    struct Node
                    {
                      int Item;      // User data item
                      Node * Succ;   // Link to the node's successor
                    };
                
                    unsigned Num;    // Current count of items in the set
                    Node * Head;     // Link to the head of the chain
                
                  public:
                
                    // Return information about the set
                    //
                    bool is_empty() const { return Num == 0; }
                    unsigned size() const { return Num; }
                
                    // Initialize the set to empty
                    //
                    Set();
                
                    // Insert a specified item into the set, if possible
                    //
                    bool insert( int );
                
                    // Display the set
                    //
                    void display( ostream& ) const;
                
                };
                

                推荐答案

                假设你的列表是循环的,你可以这样使用:

                Suppose your list is cyclical, you can use this:

                struct Node *n = begin;
                
                if (n != NULL) {
                    //do something on it
                    ...
                    for (n = begin->Succ; n != begin; n = n->Succ) {
                    }
                }
                

                struct Node *n = begin;
                if (n != NULL) {        
                    do {        
                        //do something
                        ...
                        n = n->Succ;
                    } while (n != begin)
                }
                

                这篇关于单链打印 C++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Is Type(::x); valid?(是类型(::x);有效的?)
                Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)
                  <tbody id='Kasar'></tbody>

                      <bdo id='Kasar'></bdo><ul id='Kasar'></ul>

                        <small id='Kasar'></small><noframes id='Kasar'>

                        <i id='Kasar'><tr id='Kasar'><dt id='Kasar'><q id='Kasar'><span id='Kasar'><b id='Kasar'><form id='Kasar'><ins id='Kasar'></ins><ul id='Kasar'></ul><sub id='Kasar'></sub></form><legend id='Kasar'></legend><bdo id='Kasar'><pre id='Kasar'><center id='Kasar'></center></pre></bdo></b><th id='Kasar'></th></span></q></dt></tr></i><div id='Kasar'><tfoot id='Kasar'></tfoot><dl id='Kasar'><fieldset id='Kasar'></fieldset></dl></div>
                      • <legend id='Kasar'><style id='Kasar'><dir id='Kasar'><q id='Kasar'></q></dir></style></legend>
                          <tfoot id='Kasar'></tfoot>