This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <iostream>
#include "List.hpp"
/*
由键盘输入5个整数,以这些整数作为结点数据,
生成两个链表,一个向前生成,一个向后生成,输出两个表。
然后给出一个整数在一个链表中查找,找到后删除它,再输出该表。
*/
int main()
{
List<int> list1{}, list2{};
int num{};
Node<int> *p1{}, *p2{};
std::cout << "请输入5个整数:";
for (int i{1}; i <= 5; ++i)
std::cin >> num;
p1 = new Node<int>{num};
p2 = new Node<int>{num};
list1.insert_rear(p1);
list2.insert_front(p2);
}
list1.print();
list2.print();
std::cout << "请输入要从列表1当中删除的整数:";
int new_num{};
std::cin >> new_num;
p1 = list1.find(new_num);
if (p1)
list1.delete_node(p1);