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

📄 selectionsort.cpp

📁 包含八种排序算法的界面演示多线程程序,以线段形式表示数据大小,排序一清二楚
💻 CPP
字号:
// SelectionSort.cpp: implementation of the CSelectionSort class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "sort.h"
#include "SelectionSort.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

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

CSelectionSort::CSelectionSort()
{
	name=_TEXT("选择");
}

CSelectionSort::~CSelectionSort()
{

}

void CSelectionSort::Sort()
{
	int k,temp;
	for (int i=0;i<n;i++)
	{
		k=i;
		for (int j=i;j<n;j++)
		{
//			Draw();
			if (CanSleep) Sleep();
			if (State2==-1) 
				{State2=1;return;}
			if (p[j]<p[k])
			{
				k=j;
			}
		}
		temp=p[k];
		p[k]=p[i];
		p[i]=temp;
//		Draw();
	}

	State2=2;
}

⌨️ 快捷键说明

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