📄 insertsort.cpp
字号:
// InsertSort.cpp: implementation of the CInsertSort class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "sort.h"
#include "InsertSort.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CInsertSort::CInsertSort()
{
name=_TEXT("插入");
}
CInsertSort::~CInsertSort()
{
}
void CInsertSort::Sort()
{
for (int i=1;i<n;i++)
for (int j=i;(j>0&&p[j]<p[j-1]);j--)
{
if (State2==-1)
{State2=1;return;}
int temp=p[j];
p[j]=p[j-1];
p[j-1]=temp;
if (CanSleep) Sleep();
}
State2=2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -