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

📄 bubblesort.cpp

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

#include "BubbleSort.h"

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

BubbleSort::BubbleSort()
{

}

BubbleSort::~BubbleSort()
{

}

void BubbleSort::bubbleSort()
{  
	int iTemp;  
	for(int i=1;i<BubbleSort::Count;i++)  
	{	  
		for(int j=BubbleSort::Count-1;j>=i;j--)  
		{  
			if(BubbleSort::data[j]<BubbleSort::data[j-1])
			{  
				iTemp = BubbleSort::data[j-1];  
				BubbleSort::data[j-1] = BubbleSort::data[j];  
				BubbleSort::data[j] = iTemp;  
			}  
		}  
	}  
}  
void BubbleSort::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 BubbleSort::Show()
{
	cout<<"The result is:"<<endl;
	for(int i=0;i<BubbleSort::Count;i++)
		cout<<data[i]<<"  ";
} 

⌨️ 快捷键说明

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