Skip to content

Instantly share code, notes, and snippets.

@caljim
caljim / variable_bytes_codes.c
Created February 28, 2013 08:16
整数序列压缩算法,实现了variable bytes codes,参考这里http://en.wikipedia.org/wiki/Variable-width_encoding
#include<stdio.h>
#include<stdlib.h>
struct element {
struct element *next;
unsigned char val;
};
struct element ot = {NULL,NULL};
@caljim
caljim / ssc.c
Created February 25, 2013 17:53
剪刀石头布
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
char hand[][10] = {"剪刀", "石头", "布"};
int main()
{
int computer, player, ret;
srand(time(NULL));
@caljim
caljim / combine.c
Created February 25, 2013 16:36
choose m element from n-set
#include<stdio.h>
#include<stdlib.h>
void combine(int src[], int s, int e, int k, int take[], int p)
{
if(k == e - s + 1) {
for(int i = 0; i < p; i++)
@caljim
caljim / divide_sort.c
Created January 29, 2013 17:55
Divide Sort
#include "stdio.h"
#ifndef MAXNUM
#define MAXNUM 100
#endif
void divide(int needle[], int from, int end)
{
int num = end - from;
@caljim
caljim / insert_sort.c
Created January 29, 2013 07:49
Insert Sort on Lined List
#include "insert_sort.h"
Node* find_node(int value)
{
Node *start = &root;
while(start->after != NULL) {
if(start->value == value)
return start;
else
@caljim
caljim / main.c
Created January 21, 2013 16:08
KMP Implement in C
#执行的方法
#./a.out 中国国家人民政府 人民
#输出
#
#[CONSOLE:] 中国国家人民政府
# △
# ↑表示此处匹配
#
#
@caljim
caljim / test.c
Created January 17, 2013 17:43
Simple Ternary Search Tree Implement for C
#include "trident.h"
int main(void)
{
ROOT = create_node(' ',YES);
printf("ROOT addr:%X\n",ROOT);
char* a = "he";
insert_node(a,ROOT);
insert_node("你好",ROOT);
insert_node("中国",ROOT);
@caljim
caljim / setup.py
Created September 19, 2012 04:28
Python ext compile example
form distutils.core import setup, Extension
module1 = Extension('foo',
sources = ['foo.c','hash_64a.c'])
setup (name = 'foo',
version = '0.1.3',
description = '',
classifiers=[
"Programming Language :: Python",],