Skip to content

Instantly share code, notes, and snippets.

View kimitoboku's full-sized avatar

Kento KAWAKAMi kimitoboku

View GitHub Profile
#include<stdio.h>
void hanoi(int n,char a,char b,char c){
if(n>0){
hanoi(n-1,a,b,c);
printf("一番上を%cから%cに移動\n",a,b);
hanoi(n-1,b,c,a);
}
}
@kimitoboku
kimitoboku / levenshtein.c
Created May 8, 2014 06:01
レーベンシュタイン距離
#include<stdio.h>
#include<string.h>
int min(int a, int b) {
return a<b?a:b;
}
int levenshtein(char *str1,char *str2){
int str1len = strlen(str1);
@kimitoboku
kimitoboku / qsort.c
Created May 9, 2014 13:48
quick sort
#include<stdio.h>
int Partition(int A[],int left,int right){
int x = A[left];
int i = left;
int j;
for(j=left+1;j<=right;j++){
if(A[j] < x ){
i++;
int buf = A[i];
@kimitoboku
kimitoboku / msort.c
Created May 9, 2014 13:49
merge sort
#include<stdio.h>
int temp[100];
void msort(int A[],int left,int right){
if(left >= right){
return;
}else{
int middle = (left+right)/2;
msort(A,left,middle);
msort(A,middle+1,right);
@kimitoboku
kimitoboku / logisticequation.py
Created May 15, 2014 06:50
ロジスティクスうんたらかんたら
import scipy.integrate
import numpy as np
import matplotlib.pyplot as plt
x01 = [0.2]
x10 = [0.2]
x20 = [0.2]
x25 = [0.2]
x30 = [0.2]
@kimitoboku
kimitoboku / insertionsort.c
Created May 18, 2014 14:37
intertionsort
#include<stdio.h>
void insertionsort(int array[],int n){
int i;
for(i=1;i<n;i++){
int k = array[i];
int j = i -1;
while((j>=0)&&(array[j] > k)){
array[j+1] = array[j];
j--;
#include<stdio.h>
void bubblesort(int array[],int n){
int i;
for(i=n-1;i!=0;i--){
int index;
for(index = 0; index < i ;index++){
if(array[index] > array[index+1]){
int n = array[index];
array[index] = array[index+1];
@kimitoboku
kimitoboku / main.c
Created June 5, 2014 08:34
music data list print shell
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<sys/types.h>
#include<sys/stat.h>
typedef struct {
char name[200];
char artist[200];
@kimitoboku
kimitoboku / main.c
Last active August 29, 2015 14:03
maze
#include<stdio.h>
#include<stdlib.h>
void disp(int ary[],int w,int h){
int i,j;
for(i=1;i<w-1;i++){
for(j=1;j<h-1;j++){
switch(ary[i*w + j]){
case 0:printf("#");break;
case 1:printf(".");break;
import matplotlib.pyplot as plt
import random
a1 = 1.0
a2 = 4.0
xs = []
a = []
for i in range(100000):
an = a1 + (a2 - a1) * float(i) / 100000