摘要:
/* * 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... 阅读全文
摘要:
/* * 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... 阅读全文
摘要:
/* * 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... 阅读全文
摘要:
/* * 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 ) {... 阅读全文
摘要:
#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... 阅读全文
摘要:
/* * 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 阅读全文