亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? qsort.c

?? 一個完整的C語言遺傳程序包
?? C
字號:
/*- * Copyright (c) 1980, 1983, 1990 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */#if defined(LIBC_SCCS) && !defined(lint)static char sccsid[] = "@(#)qsort.c	5.9 (Berkeley) 2/23/91";#endif /* LIBC_SCCS and not lint */#include <sys/types.h>#include <stdlib.h>#if __STDC__ || defined(__cplusplus)#define __P(s) s#else#define __P(s) ()#endif/* * MTHRESH is the smallest partition for which we compare for a median * value instead of using the middle value. */#define	MTHRESH	6/* * THRESH is the minimum number of entries in a partition for continued * partitioning. */#define	THRESH	4voidbsd_qsort(bot, nmemb, size, compar)	void *bot;	size_t nmemb, size;	int (*compar) __P((const void *, const void *));{	static void insertion_sort(), quick_sort();	if (nmemb <= 1)		return;	if (nmemb >= THRESH)		quick_sort(bot, nmemb, size, compar);	else		insertion_sort(bot, nmemb, size, compar);}/* * Swap two areas of size number of bytes.  Although qsort(3) permits random * blocks of memory to be sorted, sorting pointers is almost certainly the * common case (and, were it not, could easily be made so).  Regardless, it * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer * arithmetic gets lost in the time required for comparison function calls. */#define	SWAP(a, b) { \	cnt = size; \	do { \		ch = *a; \		*a++ = *b; \		*b++ = ch; \	} while (--cnt); \}/* * Knuth, Vol. 3, page 116, Algorithm Q, step b, argues that a single pass * of straight insertion sort after partitioning is complete is better than * sorting each small partition as it is created.  This isn't correct in this * implementation because comparisons require at least one (and often two) * function calls and are likely to be the dominating expense of the sort. * Doing a final insertion sort does more comparisons than are necessary * because it compares the "edges" and medians of the partitions which are * known to be already sorted. * * This is also the reasoning behind selecting a small THRESH value (see * Knuth, page 122, equation 26), since the quicksort algorithm does less * comparisons than the insertion sort. */#define	SORT(bot, n) { \	if (n > 1) \		if (n == 2) { \			t1 = bot + size; \			if (compar(t1, bot) < 0) \				SWAP(t1, bot); \		} else \			insertion_sort(bot, n, size, compar); \}static voidquick_sort(bot, nmemb, size, compar)	register char *bot;	register int size;	int nmemb, (*compar)();{	register int cnt;	register u_char ch;	register char *top, *mid, *t1, *t2;	register int n1, n2;	char *bsv;	static void insertion_sort();	/* bot and nmemb must already be set. */partition:	/* find mid and top elements */	mid = bot + size * (nmemb >> 1);	top = bot + (nmemb - 1) * size;	/*	 * Find the median of the first, last and middle element (see Knuth,	 * Vol. 3, page 123, Eq. 28).  This test order gets the equalities	 * right.	 */	if (nmemb >= MTHRESH) {		n1 = compar(bot, mid);		n2 = compar(mid, top);		if (n1 < 0 && n2 > 0)			t1 = compar(bot, top) < 0 ? top : bot;		else if (n1 > 0 && n2 < 0)			t1 = compar(bot, top) > 0 ? top : bot;		else			t1 = mid;		/* if mid element not selected, swap selection there */		if (t1 != mid) {			SWAP(t1, mid);			mid -= size;		}	}	/* Standard quicksort, Knuth, Vol. 3, page 116, Algorithm Q. */#define	didswap	n1#define	newbot	t1#define	replace	t2	didswap = 0;	for (bsv = bot;;) {		for (; bot < mid && compar(bot, mid) <= 0; bot += size);		while (top > mid) {			if (compar(mid, top) <= 0) {				top -= size;				continue;			}			newbot = bot + size;	/* value of bot after swap */			if (bot == mid)		/* top <-> mid, mid == top */				replace = mid = top;			else {			/* bot <-> top */				replace = top;				top -= size;			}			goto swap;		}		if (bot == mid)			break;		/* bot <-> mid, mid == bot */		replace = mid;		newbot = mid = bot;		/* value of bot after swap */		top -= size;swap:		SWAP(bot, replace);		bot = newbot;		didswap = 1;	}	/*	 * Quicksort behaves badly in the presence of data which is already	 * sorted (see Knuth, Vol. 3, page 119) going from O N lg N to O N^2.	 * To avoid this worst case behavior, if a re-partitioning occurs	 * without swapping any elements, it is not further partitioned and	 * is insert sorted.  This wins big with almost sorted data sets and	 * only loses if the data set is very strangely partitioned.  A fix	 * for those data sets would be to return prematurely if the insertion	 * sort routine is forced to make an excessive number of swaps, and	 * continue the partitioning.	 */	if (!didswap) {		insertion_sort(bsv, nmemb, size, compar);		return;	}	/*	 * Re-partition or sort as necessary.  Note that the mid element	 * itself is correctly positioned and can be ignored.	 */#define	nlower	n1#define	nupper	n2	bot = bsv;	nlower = (mid - bot) / size;	/* size of lower partition */	mid += size;	nupper = nmemb - nlower - 1;	/* size of upper partition */	/*	 * If must call recursively, do it on the smaller partition; this	 * bounds the stack to lg N entries.	 */	if (nlower > nupper) {		if (nupper >= THRESH)			quick_sort(mid, nupper, size, compar);		else {			SORT(mid, nupper);			if (nlower < THRESH) {				SORT(bot, nlower);				return;			}		}		nmemb = nlower;	} else {		if (nlower >= THRESH)			quick_sort(bot, nlower, size, compar);		else {			SORT(bot, nlower);			if (nupper < THRESH) {				SORT(mid, nupper);				return;			}		}		bot = mid;		nmemb = nupper;	}	goto partition;	/* NOTREACHED */}static voidinsertion_sort(bot, nmemb, size, compar)	char *bot;	register int size;	int nmemb, (*compar)();{	register int cnt;	register u_char ch;	register char *s1, *s2, *t1, *t2, *top;	/*	 * A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm	 * S).  Insertion sort has the same worst case as most simple sorts	 * (O N^2).  It gets used here because it is (O N) in the case of	 * sorted data.	 */	top = bot + nmemb * size;	for (t1 = bot + size; t1 < top;) {		for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;);		if (t1 != (t2 += size)) {			/* Bubble bytes up through each element. */			for (cnt = size; cnt--; ++t1) {				ch = *t1;				for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)					*s1 = *s2;				*s1 = ch;			}		} else			t1 += size;	}}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久蜜桃av一区精品变态类天堂 | 色综合色综合色综合色综合色综合 | 色综合欧美在线| 91香蕉视频在线| 不卡av电影在线播放| heyzo一本久久综合| 91精品福利视频| 欧美视频在线一区| 日韩一区二区三区视频在线| 久久亚洲一级片| 国产精品国产三级国产| 亚洲九九爱视频| 日韩在线a电影| 国产成人午夜高潮毛片| 色呦呦国产精品| 91精品久久久久久久99蜜桃 | 视频一区视频二区中文字幕| 激情深爱一区二区| 99久久综合国产精品| 欧美性感一区二区三区| 欧美绝品在线观看成人午夜影视| 欧美v国产在线一区二区三区| 中文av字幕一区| 亚洲午夜视频在线| 国产成人在线视频网站| 欧美日韩精品一区二区三区四区| 欧美tickle裸体挠脚心vk| 国产日韩欧美不卡| 亚洲国产欧美在线| 国产精品亚洲第一 | 欧美午夜宅男影院| 久久久亚洲精华液精华液精华液 | 日本久久一区二区三区| 91精品国产美女浴室洗澡无遮挡| 久久亚洲二区三区| 亚洲综合免费观看高清完整版| 国内不卡的二区三区中文字幕 | 成人性生交大合| 欧美精品v国产精品v日韩精品| 国产亚洲一区二区三区四区 | 成人免费看视频| 91精品国产福利| 国产欧美一区二区精品仙草咪| 亚洲成人免费av| 国产精品69久久久久水密桃 | 亚洲国产精品人人做人人爽| 国产一区不卡视频| 91久久一区二区| 久久色.com| 亚洲成国产人片在线观看| 成人丝袜高跟foot| 日韩视频不卡中文| 亚洲成人福利片| a4yy欧美一区二区三区| 久久美女艺术照精彩视频福利播放| 亚洲国产精品一区二区久久恐怖片| 国产大陆亚洲精品国产| 日韩久久久久久| 日韩高清不卡一区二区| 国产**成人网毛片九色| 7777精品伊人久久久大香线蕉| 1000精品久久久久久久久| 男人的j进女人的j一区| 欧美男生操女生| 最新中文字幕一区二区三区| 国产黄色精品视频| 久久综合色天天久久综合图片| 日本欧美加勒比视频| 欧美在线观看18| 国产亚洲精品福利| 国产一区二区三区最好精华液| 91精品一区二区三区在线观看| 曰韩精品一区二区| 91免费国产视频网站| 国产精品免费久久| 国产九色sp调教91| 久久久久久久久岛国免费| 久久99国产精品麻豆| 日韩视频免费直播| 日韩在线观看一区二区| 欧美综合一区二区| 夜夜精品浪潮av一区二区三区| 色拍拍在线精品视频8848| 亚洲私人影院在线观看| 91亚洲永久精品| 亚洲人精品午夜| 色天天综合久久久久综合片| 亚洲免费av高清| 日本道在线观看一区二区| 亚洲最新视频在线播放| 精品视频全国免费看| 亚洲图片一区二区| 欧美精品vⅰdeose4hd| 日本午夜精品视频在线观看 | 久久久久久综合| 久久精品久久精品| 26uuu亚洲综合色| 国产一区二区电影| 欧美极品xxx| 99久久精品一区二区| 一区在线播放视频| 91丨porny丨在线| 中文字幕一区二区三区不卡| 91在线观看视频| 亚洲一区精品在线| 91精品久久久久久久91蜜桃| 精品无人区卡一卡二卡三乱码免费卡| 欧美日韩三级在线| 日本v片在线高清不卡在线观看| 日韩免费高清电影| 国产999精品久久| 亚洲国产精品ⅴa在线观看| 99精品久久99久久久久| 亚洲电影一级黄| 日韩亚洲欧美高清| 91影院在线免费观看| 麻豆精品在线播放| 综合久久国产九一剧情麻豆| 欧美一卡2卡三卡4卡5免费| 成人国产精品免费观看视频| 亚洲sss视频在线视频| 精品国产99国产精品| 日本韩国欧美在线| 国产精品亚洲一区二区三区妖精 | 欧美日韩国产影片| 国产不卡高清在线观看视频| 亚洲午夜免费视频| 国产色综合久久| 91麻豆精品国产91久久久 | 亚洲精品日韩专区silk| 欧美xfplay| 欧美三级韩国三级日本一级| 国产成人日日夜夜| 免费成人av资源网| 亚洲影视在线观看| 久久久国产精华| 欧美一区二区福利视频| 99re这里只有精品6| 国产在线精品免费av| 五月婷婷久久综合| 日本一区二区三区在线不卡| 制服丝袜一区二区三区| 91一区一区三区| 成人性生交大合| 黄页网站大全一区二区| 亚洲成人免费看| 亚洲欧美一区二区三区孕妇| 久久久精品国产99久久精品芒果 | 久久99最新地址| 性做久久久久久免费观看欧美| 1000部国产精品成人观看| 精品处破学生在线二十三| 91精品国产欧美一区二区18| 91久久国产最好的精华液| 成人黄色小视频| 另类调教123区| 天堂蜜桃一区二区三区| 一区二区不卡在线视频 午夜欧美不卡在 | 亚洲影院在线观看| 亚洲欧美日韩国产手机在线| 中文子幕无线码一区tr| 欧美刺激午夜性久久久久久久| 欧美人牲a欧美精品| 欧美在线观看18| 一本色道久久综合狠狠躁的推荐| 国产精一区二区三区| 久色婷婷小香蕉久久| 日韩av在线播放中文字幕| 亚洲一区二区三区四区在线观看| 亚洲色图制服诱惑| 中文字幕制服丝袜一区二区三区| 国产亚洲综合在线| 久久久久久9999| 国产日韩欧美精品在线| 久久精品一区四区| 国产欧美日韩另类视频免费观看| 久久精品视频免费| 国产亚洲精品超碰| 国产精品私人影院| 国产精品视频看| 日本一区二区免费在线| 国产精品欧美久久久久无广告| 国产精品三级久久久久三级| 欧美激情自拍偷拍| 亚洲少妇屁股交4| 一区二区三区国产精品| 一个色综合av| 亚洲一区二区偷拍精品| 亚洲国产精品久久久男人的天堂| 一二三区精品福利视频| 亚洲欧美另类在线| 亚洲国产综合色| 日韩黄色在线观看| 日韩国产一二三区| 久久精品国产99久久6| 国产毛片一区二区| 成人网页在线观看| 日本韩国欧美三级| 91美女在线观看| 欧美日韩一区二区不卡|