09 2011 档案

摘要:#__author__=lx#__date__=2011-09-29#__brief__=Heap_sortdef left( i ): return 2*idef right( i ): return 2*i + 1def swap( a1, a2 ): return a2, a1def max_heap( A, i ): if i == 0: return l = left( i ) r = right( i ) largest = i if l <... 阅读全文
posted @ 2011-09-29 18:51 lxgeek 阅读(130) 评论(0) 推荐(0) 编辑
摘要:#__author__=lx#__date__=2011-09-27#__brief_=shell_sortdef shell_sort( l ): gap = 0 n = len( l ) while ( gap <= n ): gap = gap * 3 + 1 while ( gap > 0 ): i = gap while ( i < n ): j = i - gap ... 阅读全文
posted @ 2011-09-27 09:29 lxgeek 阅读(138) 评论(0) 推荐(0) 编辑
摘要:#__author__=lx#__date__=2011-09-26#__brief__=bubble_sortdef swap( a1, a2 ): return a2, a1def bullble_sort( l ): b = l for i in l: n = b.index( i ) j = 0 q = True while ( j < len( l ) - n - 1 ): if... 阅读全文
posted @ 2011-09-26 15:24 lxgeek 阅读(171) 评论(0) 推荐(0) 编辑
摘要:/* * author:lx * breif: 2011.09.22 * brief: quick-sort */#include <stdio.h>#include <stdlib.h>voidquick_sort( int *x, int l, int u ){ if ( l >= u ) { return; } int m = l; int i; for ( i = l+1; i < u; i++ ) { if ( x[i] < x... 阅读全文
posted @ 2011-09-22 19:25 lxgeek 阅读(128) 评论(0) 推荐(0) 编辑
摘要:/* * author:lx * date:2011.09.22 * brief: insertion-sort */#include <stdio.h>#include <stdlib.h>void insertion_sort( int *p, int len ){ int j = 1; int key = 0; int i; for ( ; j < len; j++ ) { key = p[j]; i = j - 1; while... 阅读全文
posted @ 2011-09-22 16:17 lxgeek 阅读(138) 评论(0) 推荐(0) 编辑
摘要:/* * brief: genericity programming * */#include <stdio.h>#include <stdlib.h>#include <assert.h>#define GENERIC_STACK( STACK_TYPE, SUFFIX, STACK_SIZE ) \ \ static STACK_TYPE stack##SUFFIX[ STACK_SIZE ]; \ st... 阅读全文
posted @ 2011-09-17 15:56 lxgeek 阅读(168) 评论(0) 推荐(0) 编辑
摘要:/* * author: lx * date: 2011-09-16 * brief: programming pearls column2 */#include <stdio.h>#include <stdlib.h>voidmove_vector( char* b, int m, int n ){ int i = 0; int j; char temp; for ( ; i < n ; i++ ) { for ( j = i; j < m; j += n ) {... 阅读全文
posted @ 2011-09-17 13:23 lxgeek 阅读(178) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>#include <stdlib.h>typedef unsigned char *byte_pointer;voidshow_bytes( byte_pointer start, int len ){ int i; for ( i = 0; i < len; i++ ) printf( " %.2x", start[i] ); printf( "\n" );}voidshow_int( int x ){ show_bytes( ( byte_pointer )&x, si... 阅读全文
posted @ 2011-09-15 19:13 lxgeek 阅读(198) 评论(0) 推荐(0) 编辑
摘要:/* * author: lx * date: 2011-09-08 * brief: the interface of list * file: llist.c */#include <stdio.h>#include <stdlib.h>#include "llist.h"intinsert_list( register Node **linkp, int new_value ){ register Node *current; register Node *new; while ( ( current = *linkp ) != NULL &a 阅读全文
posted @ 2011-09-15 16:27 lxgeek 阅读(156) 评论(0) 推荐(0) 编辑