⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 try_list.cpp

📁 这是数据结构初学者的极佳参考资料,里面有关意向链表的实现.
💻 CPP
字号:
#include "stdafx.h"
#include "list.h"

void main()
{
	int choose = -1, max_length, record, position;
	cout << "max_length:";
	cin >> max_length;

	list<int> t_list(max_length);

	while (choose != 0)
	{
		cout << endl << "-----------------------------" << endl
			 << "1.empty" << endl
			 << "2.full" << endl
			 << "3.size" << endl
			 << "4.clear" << endl
			 << "5.insert" << endl
			 << "6.remove" << endl
			 << "7.retrieve" << endl
			 << "8.replace" << endl
			 << "9.show the list" << endl
			 << "0.exit" << endl;
		cin >> choose;

		switch (choose)
		{
		case 1: 
			if (t_list.empty()) cout << "the list is empty" << endl;
			else cout << "the list is not empty" << endl;
			break;
		case 2:
			if (t_list.full()) cout << "the list is full" << endl;
			else cout << "the list is not full" << endl;
			break;
		case 3:
			cout << "the size of the list is " << t_list.size() << endl;
			break;
		case 4:
			t_list.clear();
			break;
		case 5:
			cout << "new record:";
			cin >> record;
			cout << "position:";
			cin >> position;
			t_list.insert(position, record);
			break;
		case 6:
			cout << "position:";
			cin >> position;
			t_list.remove(position);
			break;
		case 7:
			cout << "position:";
			cin >> position;
			t_list.retrieve(position, record);
			cout << "[" << position << "]:\t" << record;
			break;
		case 8:
			cout << "new record:";
			cin >> record;
			cout << "position:";
			cin >> position;
			t_list.replace(record, position);
			break;
		case 9:
			for (position = 0; position < t_list.size(); position++)
			{
				t_list.retrieve(position, record);
				cout << "[" << position << "]:\t" << record << endl;
			}
			break;
		default: break;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -