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