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

📄 application.cpp

📁 各种常用的排序算法的演示程序
💻 CPP
字号:
#include "Application.h"

Application::Application()
{
	SeqList<int> list;
	Sort<int> S;
}

void Application::Initial()
{	
	for(int i=10;i>0;i--)
	{
		list.Insert(i);	
	}
	cout<<"\tBefore Sorted:"<<endl;
	cout<<"\t"<<list;
	cout<<endl;
}

int Application::MenuSelect()
{
	int cn=0;
	cout<<"\t******************************************"<<endl;
	cout<<"\t           Sort Simulation 1.0           "<<endl;
	cout<<"\t           producer:Sapphire_Lee           "<<endl;
	cout<<"\t           all rights reserved!"<<endl;
	cout<<"\t******************************************"<<endl;
	cout<<endl
	    <<"\t1.InsertionSort"<<endl
		<<"\t2.BinaryInsertSort"<<endl
		<<"\t3.ShellSort"<<endl
		<<"\t4.BubbleSort"<<endl
		<<"\t5.QuickSort"<<endl
		<<"\t6.SelectSort"<<endl
		<<"\t7.HeapSort"<<endl
		<<"\t8.Exit "<<endl;
	for( ; ; )
	{
		cout<<"\t";
		cin>>cn;
		if(cn<1||cn>8)
			cout<<endl<<"\tError Input,Please input1-8"<<endl;
		else
			break;
	}
	return cn;
}

void Application::HandleMenu()
{
	for( ; ; )
	{
		switch(MenuSelect())
		{
		case 1:
			{
				Initial();
				S.InsertionSort(list);
				cout<<"\tAfter Sorted:"<<endl;
				cout<<"\t"<<list;
				cout<<endl;
				list.Remove();
				break;
			}
		case 2:	
			{
				Initial();
				S.BinaryInsertSort(list);
				cout<<"\tAfter Sorted:"<<endl;
				cout<<"\t"<<list;
				cout<<endl;
				list.Remove();
				break;
			}
		case 3:
			{
				Initial();
				S.ShellSort(list);
				cout<<"\tAfter Sorted:"<<endl;
				cout<<"\t"<<list;
				cout<<endl;
				list.Remove();
				break;
			}
		case 4:
			{
				Initial();
				S.BubbleSort(list);
				cout<<"\tAfter Sorted:"<<endl;
				cout<<"\t"<<list;
				cout<<endl;
				list.Remove();
				break;
			}
		case 5:
			{
				Initial();
				S.QuickSort(list,0,list.GetPos());
				cout<<"\tAfter Sorted:"<<endl;
				cout<<"\t"<<list;
				cout<<endl;
				list.Remove();
				break;
			}
		case 6:
			{
				Initial();
				S.SelectSort(list);
				cout<<"\tAfter Sorted:"<<endl;
				cout<<"\t"<<list;
				cout<<endl;
				list.Remove();
				break;
			}
		case 7:
			{
				Initial();
				S.HeapSort(list);
				cout<<"\tAfter Sorted:"<<endl;
				cout<<"\t"<<list;
				cout<<endl;
				list.Remove();
				break;
			}
			break;
		case 8:
			cout<<"\tBye!"<<endl;
			exit(1);
		}
	}
}

⌨️ 快捷键说明

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