如何在链接列表中存储数字列表
How to store a list of numbers in a link list
我一直在尝试将数组的数字存储在链接列表中。但我不知道该怎么做。我需要有人帮我完成代码。
#include <iostream>
using namespace std;
int main()
{
int numeros[9] = {1,2,3,4,5,6,7,8,9};
typedef struct Node *NodePtr; //declara Nodeptr un apuntador a Node
struct Node
{
int x;
Node *next; // omit the 'struct' for C++-only usage
};
return 0;
}
压缩方式:
struct Node
{
int x;
Node *next;
} nodes[] = {
{1, nodes + 1},
{2, nodes + 2},
{3, nodes + 3},
{4, nodes + 4},
{5, nodes + 5},
{6, nodes + 6},
{7, nodes + 7},
{8, nodes + 8},
{9, nullptr}
};
Node* root = nodes;
相关文章:
- 如何(从固定列表中)选择一个数字序列,该序列将与目标数字相加
- 试图在c++中对数字列表进行排序
- 如果我不知道每个列表中有多少个数字,我如何将给定数量的数字列表作为输入?
- 如何优化代码以返回最接近给定整数的数字,但给定列表中不存在?
- 按唯一标识符描述数字列表
- 从小于或等于某个 N 的数字列表中最小化或找到 n 个理想的子集和
- C++ 分段错误:11 错误,同时编码将两个数字相加的链接列表
- 用于筛子的最佳数据结构是什么(即一些被划掉的数字列表)?
- 最大数量.给定一个非负整数列表,排列它们以使它们形成最大的数字
- 从(排序的)数字列表中获取数字范围
- 如何在C++中创建 2d 数组,其中一部分包含循环计数器,另一部分包含数字列表?
- 如何在C++中创建数字列表,以便它可以选择一个随机数?
- C - 将数字添加到列表中?(就像python)
- 可以将数字的大括号列表用作传递给可变参数函数(或构造函数)的参数吗?
- 输入正整数或负整数列表,以使用开关函数 c++ 确定数字是偶数还是奇数
- 使用数字列表和算术运算获取目标数字
- 如何通过C 从数字列表中以3位数字生成数字
- 成员初始化列表中初始化的向量与传递给构造函数的数字不同
- 卡在 if 语句中,以检查列表中的数字
- 在 c++ 中将数字从列表排序到数组中的气泡排序问题