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

📄 quick.c

📁 快速排序的递归解演示
💻 C
字号:
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<time.h>
#include<conio.h>

int split(int a[20],int l,int h)
{
	int i,j;
	int x;
	i=l;
	j=h;
	x=a[i];
	while(i<j)
	{
		while((i<j)&&(a[j]>=x))
			j--;
		if(i<j)
		{
			a[i]=a[j];
			i++;
		}
		while((i<j)&&(a[i]<=x))
			i++;
		if(i<j)
		{
			a[j]=a[i];
			j--;
		}
	}
	a[i]=x;
	return(i);
}
/*****************************************/
void qqqsort(int a[20],int l,int h)
{
	int i,k,c;
	if(l<h)
	{
		i=split(a,l,h);
	/*********/
		for(k=l;k<=h;k++)
		{
			   gotoxy(1,k+1);
			   clreol();
				 for(c=1;c<=a[k];c++)
				   printf("*");

		 }
		 delay(10000);
   /*********/
		qqqsort(a,l,i-1);
		qqqsort(a,i+1,h);
	}
}
/*****************************************/
main()
{ 
  int d[20],h;
  int i,k,c;
  clrscr();
  textbackground(1);
  textcolor(14);
  gotoxy(1,22);
printf("Welcome	to the BlueSourceCode web site in http://lsdmzz.126.com\n");
printf("\n");
printf("		Written by LiuXu  E-mail: hlxhlx8888@sina.com\n");

  for(h=0;h<=19;h++)
	{
	  randomize();

	  d[h]=((h*h+random(300)+h*random(2))%70)+1;
	}
 /*********/
   for(k=1;k<=20;k++)
		{
				   gotoxy(1,k);
				 for(c=1;c<=d[k-1];c++)
				   printf("*");

				 printf("\n");

				 }
  /*********/
qqqsort(d,0,19);
gotoxy(1,24);
clreol();
printf("Press any key to exit...\n");
getch();


}

⌨️ 快捷键说明

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