This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import sys | |
import numpy as np | |
from math import log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
sys.path.append('../') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding:utf-8 -*- | |
num_list = range(10) | |
# use for roop | |
list_sum = 0 | |
for num in num_list : | |
list_sum += num | |
print 'list_sum counted with for roop :', list_sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pivot_index (int n, int *a) { | |
int i; | |
for (i=1; i<n; i++) { | |
if (a[i] != a[0]) { | |
// pivot exists | |
return a[i] > a[0] ? i : 0; | |
} | |
} | |
// pivot not exists | |
return -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void insertion_sort (int n, int *a) { | |
int i, j, swap; | |
for (i=1; i<n; i++) { | |
j = i-1; | |
while (j>=0 && a[j]>a[j+1]) { | |
swap = a[j]; | |
a[j] = a[j+1]; | |
a[j+1] = swap; | |
j--; | |
} |
NewerOlder