Skip to content

Instantly share code, notes, and snippets.

View lotabout's full-sized avatar

Jinzhou Zhang lotabout

View GitHub Profile
@lotabout
lotabout / fact.c
Last active August 29, 2015 13:57
compute the fact fo a very large number.
#include <stdio.h>
int multi(char *a, int len, int b)
{
int i;
int carry = 0;
for (i = 0; i < len; i++) {
int tmp = (a[i] - '0') * b + carry;
a[i] = tmp % 10 + '0';
@lotabout
lotabout / kmp.c
Created March 20, 2014 08:48
the KMP algorithm for indexing sub-strings.
#include <stdio.h>
#include <string.h>
#include <malloc.h>
int *build_next(const char *pat, int pat_len)
{ int i;
int *next = (int *)malloc(pat_len * sizeof(*next));
next[0] = -1;
@lotabout
lotabout / jinzhou_7_perm.c
Last active August 29, 2015 13:57
print all permutation of a list
#include <stdio.h>
#include <malloc.h>
#include <string.h>
/* two solution:
* 1. function "perm"
* 2. function "print_permutation"
*/
void swap(int data[], int a, int b)
@lotabout
lotabout / liushi_7_perm.java
Created March 20, 2014 06:34
Liu, Shi's solution of permutation of 7 number.
package demo;
import java.util.ArrayList;
import java.util.List;
public class demo {
static List<String> cout(List<String> one,String str){
List<String> t = new ArrayList<String>();
@lotabout
lotabout / f1.hs
Created May 26, 2012 03:00
sssfd
magic :: Int -> Int -> [Int]
magic 0 _ = []
magic m n = m : (magic n (m+n))
getIt :: [Int] -> Int -> Int
getIt [] _ = 0
getIt (x:xs) 1 = x
getIt (x:xs) n = getIt xs (n-1)