d::endl;
for (int64_t i = linear_list.length() - 1; i >= 0; --i)
{
std::cout << linear_list.get_element(i) << " ";
}
std::cout << std::endl << std::endl;
std::cout << "第2个节点已删除,再次遍历结果为:" << std::endl;
for (int64_t i = 0; i < linear_list.length(); ++i) {
std::cout << linear_list.get_element(i) << " ";
}
std::cout << std::endl << std::endl;
std::cout << "删除第2个节点: " << std::endl;
linear_list.delete_node(2, data);
std::cout << data << std::endl << std::endl;
std::cout << "逆向遍历节点:" << std::endl;
for (int64_t i = linear_list.length() - 1; i >= 0; --i)
{
std::cout << linear_list.get_element(i) << " ";
}
std::cout << std::endl << std::endl;
std::cout << "第2个节点已删除,再次遍历结果为:" << std::endl;
for (int64_t i = 0; i < linear_list.length(); ++i) {
std::cout << linear_list.get_element(i) << " ";
}
std::cout << std::endl << std::endl;
return 0;
}
运行结果为:
代码下载地址:https://github.com/wuhui2356/data_structure/tree/master/LinearList
|