This file contains hidden or 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
/* | |
SELECTION-SORT(A) | |
1 for j ← 1 to length[A] - 1 | |
2 do min ← j | |
3 for i ← j+1 to length[A] | |
4 do if A[i] < A[min] | |
5 then min ← i | |
6 <> swap two numbers | |
7 tmp ← A[j] | |
8 A[j] ← A[min] |
This file contains hidden or 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
/* | |
INSERTION-SORT(A) | |
1 for j ← 2 to length[A] | |
2 do key ← A[j] | |
3 <> Insert A[j] into the sorted sequence A[1...j - 1]. | |
4 i ← j - 1 | |
5 while i > 0 and A[i] > key | |
6 do A[i + 1] ← A[i] | |
7 i ← i - 1 | |
8 A[i + 1] ← key |
This file contains hidden or 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
#include <stdio.h> | |
void qsort(int *array, int left, int right); | |
int main() | |
{ | |
int array[] = {8,2,6,12,1,9,5}; | |
int i = 0; | |
qsort(array, 0, 6); | |
This file contains hidden or 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
// ELF Hash Function | |
unsigned int ELFHash(char *str) | |
{ | |
unsigned int hash = 0; | |
unsigned int x = 0; | |
while (*str) | |
{ | |
hash = (hash << 4) + (*str++);//hash左移4位,当前字符ASCII存入hash低四位。 |
This file contains hidden or 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
function pretty_date($time) { | |
$diff = time() - $time; | |
$day_diff = floor($diff / 86400); | |
if(is_nan($day_diff)) return ''; | |
if ($day_diff == 0) { | |
if ($diff < 60) { | |
return $diff . "second ago"; | |
} else if ($diff < 120) { |
This file contains hidden or 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
# Ruby 1.9.2 | |
# Home: https://gist.github.com/856219 | |
# My CPP template: template_cpp.rb | |
# OJ Support: | |
# Online Judge of Zhejiang University | |
# Author: [email protected] | |
require 'uri' | |
require 'net/http' | |
#require 'hpricot' |
This file contains hidden or 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
#run: shoes this-file.rb | |
require 'stringio' | |
require "./ruby_warrior/lib/ruby_warrior.rb" | |
$wait_input = false | |
# Name Show | |
$game_name = "Ruby Warrior!" | |
# Absolut coordinate of the Map |
NewerOlder