main.cpp

来自「模块化的链表的示例」· C++ 代码 · 共 60 行

CPP
60
字号
#include "class.h"
#include <iostream.h>
#include <time.h>
#include <stdlib.h>


void main( void )
{
	time_t t = 0;
	srand( ( unsigned ) time( & t ) ); 

	int uii = 0, uij = 0;
	cout << "Please input the node's number:   ";
	cin >> uii;
	while ( ( uii < 1 ) || ( uii > MAXSIZE ) )
	{
		cout << "Bad input, try again" << endl;
		cin >> uii;
	}
    clsList_c cllist( uii );
	cout << "The created list is:" << endl;
	cllist.PrintList();
	cllist.IsFull();
	cout << "Please input the node's value and it's position:   " << endl;
	cin >> uii >> uij;
	while ( ( uii < 0 ) || ( uii > MAXSIZE ) )
	{
		cout << "Bad input, try again" << endl;
		cin >> uii >> uij;
	}
	cllist.Insert( uii, uij );
	cout << "The inserted list is:" << endl;
	cllist.PrintList();
	cout << "Now you can input a position to delete a node:" << endl;
	cin >> uii;
	while ( ( uii < 0 ) || ( uii > MAXSIZE ) )
	{
		cout << "Bad input, try again" << endl;
		cin >> uii;
	}
	cllist.Delete( uii );
	cout << "The deleted list is:" << endl;
	cllist.PrintList();
	cllist.IsFull();
	cllist.IsEmpty();


	clsList_c cllist2( cllist );
	cout << "The new list is created and it is:" << endl;
	cllist2.PrintList();

	clsList_c cllist3;
	cllist3 = cllist;
	cout << "The new list is created and it is:" << endl;
	cllist3.PrintList();

	clsList_c cllist4;
	cllist4 = cllist3 + cllist2;
	cllist4.PrintList();
}

⌨️ 快捷键说明

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