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

📄 冒泡排序.txt

📁 C语言数据结构源代码
💻 TXT
字号:
///////////////////////////////////////////////
//			作者:03031A班  李戬			 //
//											 //
//		   2003年  12月 28日   晚			 //
///////////////////////////////////////////////
#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
#define N 25000

void BUBBLESORT(int R[])
{ 
	int i,j,noswap;
	int k;
	int temp;
	for (i=1; i<=N-1; i++)
	{
		noswap=1;
		for (j=N; j>=i+1;j--)
		if (R[j]<R[j-1])
        { 
			temp=R[j];
			R[j]=R[j-1];
			R[j-1]=temp;
			noswap=0;
        }
		if (noswap) break;
   }
	for(k=1;k<=N;k++)
		cout<<ends<<R[k]<<ends<<ends;
}


void main(void)
{
	int r[N];
	int i;
	clock_t start,end;
	double duration;
	
	for(i=1;i<=N;i++)
	{
		r[i]=rand()%50000;//产生随机数
	}
	start=clock();
	//在此处插入排序的函数
	BUBBLESORT(r);
	
	end=clock();
	duration = (double)(end - start) / CLOCKS_PER_SEC;
	cout<<endl<<duration<<endl;

}


⌨️ 快捷键说明

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