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

📄 selectsort.cpp

📁 四种排序算法的比较
💻 CPP
字号:
// SelectSort.cpp: implementation of the SelectSort class.
//
//////////////////////////////////////////////////////////////////////

#include "SelectSort.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

SelectSort::SelectSort()
{

}

SelectSort::~SelectSort()
{

}

void SelectSort::selectSort()
{
	int i,j,min,temp;
	for(i=0;i<SelectSort::Count-1;i++)
	{
		min=i;
		for(j=i+1;j<SelectSort::Count;j++)
			if(SelectSort::data[j]<SelectSort::data[min])
			min=j;
		if(min!=i)
		{
			temp=SelectSort::data[min];
			SelectSort::data[min]=SelectSort::data[i];
			SelectSort::data[i]=temp;
		}
	}
} 

void SelectSort::Init(int n)
{
	data=new int[n];
	Count=n;
	cout<<"Please input the data:"<<endl;
	for(int i=0;i<n;i++)
		cin>>data[i];
} 
void SelectSort::Show()
{
	cout<<"The result is:"<<endl;
	for(int i=0;i<SelectSort::Count;i++)
		cout<<data[i]<<"  ";
} 

⌨️ 快捷键说明

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