Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¿ìËÙÅÅÐò(QuickSort)CÓïÑÔ°æ

¿ìËÙÅÅÐòµÄºËÐÄÔÚÓÚ·ÖÖÎ.
·ÖÖÎËã·¨:
1. È϶¨Ö»ÓÐÒ»¸öÔªËØ»òûÓÐÔªËØµÄÊý×éÊÇÓÐÐòµÄ.
2. ½«Êý×é°´ÕÕÒ»¸ö·Ö½çÖµ·ÖΪ×óÓÒÁ½²¿·Ö. ×óÃæËùÓÐÔªËØÖµ±È·Ö½çֵС, ÓÒÃæËùÓÐÔªËØÖµ±È·Ö½çÖµ´ó»òµÈÓÚ.
3. ½«×óÓÒÁ½²¿·Ö·Ö±ðÔÙ·ÖÖÎ, Ö±µ½Òª·ÖÖ§µÄ²¿·ÖÖ»ÓÐÒ»¸öÔªËØ»òûÓÐÔªËØ, ÄÇôÕû¸öÊý×é¾ÍÊÇÓÐÐòµÄÁË.
×÷Õß: selfimpr
²©¿Í: http://blog.csdn.net/lgg201
ÓÊÏä: lgg860911@yahoo.com.cn
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define LENGTH 500000
/*
* ´òÓ¡Ò»¸öÖ¸¶¨µÄÊý×é
*/
void printArray(int array[], int length);
/*
* ½«Ö¸¶¨Êý×éµÄÖ¸¶¨²¿·Ö·ÖÖÎ, ·µ»Ø·ÖÖεã.
* @argument division: ·Ö½çµã(ϱê)
* @argument left: ·ÖÖβ¿·ÖµÄ×óϱê
* @argument right: ·ÖÖβ¿·ÖµÄÓÒϱê
*/
int part(int array[], int division, int left, int right);
/*
* ÅÅÐòÖ¸¶¨Êý×éµÄÖ¸¶¨Î»ÖÃÔªËØ.
*/
void sort(int array[], int left, int right);
/*
* @author: selfimpr
* @blog: http://blog.csdn.net/lgg201
* @email: lgg860911@yahoo.com.cn
*/
int main() {
int array[LENGTH];
int i;
srand( (unsigned) time(NULL) );
for(i = 0; i < LENGTH; i ++) {
array[i] = rand() % LENGTH;
}
/*
* printArray(array, LENGTH);
* printf("\n\n");
*/
clock_t start = clock();
printf("Start at %d.\n", (unsigned)start);
sort(array, 0, LENGTH - 1);
clock_t end = clock();
printf("End at %d.\n", (unsigned)end);
/*
* printArray(array, LENGTH);
*/
printf("Sorted %d numbers in %d millisecond.", LENGTH, (unsigned)end - (unsigned)start);
return 0;
}
void printArray(int array[], int length) {
int i;
for(i = 0; i < length; i ++) {
printf("%d ", array[i]);
if((i + 1) % 10 == 0) {
printf("\n");
}
}
}
/*
* ·ÖÖÎËã·¨:
* ÒÔdivisionϱêµÄÔªËØÖµÎª·Ö½çµã, ½«Êý×é·Ö³É×óÓÒÁ½¸ö²¿·Ö.
* ·µ»Ø·Ö½çµãµÄϱê.
* ¹ý³Ì:
* 1. ±£Áô·Ö½çµãÔªËØµÄÖµ.
* 2. ÒÆ¶¯×óÖ¸Õë, Ö±µ½Ò»¸öÖµ²»Ð¡ÓÚ·Ö½çÖµ.
* 3. ÅжÏÊÇ·ñÒѾ­»®·ÖÁËËùÓÐÔªËØ, Èç¹ûÊÇ, Ìø³ö.
* 4. ½«×óÖ¸ÕëĿǰµÄÖµ¸´ÖƵ½divisionλÖÃ, Ö


Ïà¹ØÎĵµ£º

C·¢Éù³ÌÐò

#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <math.h>
#include <conio.h>
typedef struct {
      short int pitch;
      short int duration;
} NOTE;
NOTE notes[] = {{14, 500}, {16, 500}, {12, 500 ......

ÔÚs3c2410ÉÏÔËÐÐlinuxµÄ·½·¨

1. ×¼±¸¹¤×÷£º
¿ª·¢°åµÄipÉèÖÃ
gzsd> net set ipaddr 192.168.0.11 ÉèÖÿª·¢°åµÄIP
gzsd> net set serverip 192.169.0.10 ÉèÖÃtftp serverµÄIP
gzsd> net set netmask 255.255.255.0 ÉèÖÃ×ÓÍøÑÚÂë
gzsd> net save ±£´æÉèÖÃ
gzsd> net ping XXX ²âÊÔÁ¬½Ó×´¿ö
°²×°tftp·þÎñÆ÷
windowsÏÂ
ÔËÐйâÅ̹¤¾ß ......

ÔÚAIX»úÆ÷ÉϵÄC³ÌÐò

¡¾checkpass.c¡¿
#include <stdio.h>
#include <string.h>
 
int checkpass(void){
   int x;
   char a[9];
   x = 0;
   fprintf(stderr,"a at %p and\nx at %p\n", (void *)a, (void *)&x);
   printf("Enter a short word: ");
&nbs ......

CµÄÀúÊ·

CµÄÓÉÀ´
CÓïÑÔÊÇÓÉUNIXµÄÑÐÖÆÕßDennis RitchieºÍKen ThompsonÓÚ1970ÄêÑÐÖÆ³öµÄBÓïÑԵĻù´¡ÉÏ·¢Õ¹ºÍÍêÉÆÆðÀ´µÄ.
CµÄÌØµã
CÓïÑÔÊÇÒ»ÖÖÃæÏò¹ý³ÌµÄÓïÑÔ,ͬʱ¾ßÓлã±àÓïÑԺ͸߼¶ÓïÑÔµÄÓŵã.CÓïÑÔ¿ÉÒԹ㷺ӦÓÃÓÚ²»Í¬µÄ²Ù×÷ϵͳ,ÈçUNIX,DOS,Windows¼°LinuxµÈ.
CµÄ·¢Õ¹
1973Äê,CÓïÑÔµÚÒ»´Î±»ÓÃÀ´±àд²Ù×÷ϵͳ(Unix)µÄÄÚºË.Denn ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ