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
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32 | |
global start | |
section .text | |
start: | |
push dword msg.len | |
push dword msg | |
push dword 1 | |
mov eax, 4 |
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
<?php | |
public function testSetCookieAction() | |
{ | |
$value = '12345'; | |
$html = '<html><body>test set cookie varName =' . $value . '</body></html>'; | |
$response = new Response($html); | |
$response->headers->setCookie(new Cookie('varName', $value, time() + (3600 * 48))); | |
return $response; | |
} |
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
<?php | |
// 希排 | |
function shell_sort (&$arr) { | |
$len = count($arr); | |
$h = 1; | |
while ($h < intval($len / 3)) { | |
$h = 3*$h + 1; | |
} |
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
# 希排 | |
class Array | |
def shell_sort! | |
len = self.length | |
h = 1 | |
while h < len / 3 | |
h = 3*h + 1 | |
end | |
while h >= 1 |
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
<?php | |
// 选排 | |
function select_sort (&$arr) { | |
$len = count($arr); | |
for ($i = 0; $i < $len; ++$i) { | |
$min = $i; | |
for ($j = $i + 1; $j < $len; ++$j) { | |
if ($arr[$j] < $arr[$min]) { | |
$min = $j; |
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
# 选排 | |
class Array | |
def select_sort! | |
len = self.length | |
0.upto(len - 1) do |i| | |
min = i | |
(i + 1).upto(len - 1) do |j| | |
min = j if self[j] < self[min] | |
end | |
self[i], self[min] = self[min], self[i] if min != i |
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
<?php | |
// 插排 | |
function insert_sort (&$arr) { | |
$len = count($arr); | |
for ($i = 1; $i < $len; ++$i) { | |
for ($j = $i; $j >= 1; --$j) { | |
if ($arr[$j] < $arr[$j - 1]) { | |
$temp = $arr[$j]; | |
$arr[$j] = $arr[$j - 1]; |
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
# 插排 | |
class Array | |
def insert_sort! | |
len = self.length | |
1.upto(len - 1) do |i| | |
i.downto(1) do |j| | |
self[j], self[j - 1] = self[j - 1], self[j] if self[j] < self[j -1] | |
end | |
end | |
end |
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
<?php | |
// 二分 | |
function binary_search ($arr, $key) { | |
list($lo, $hi) = array(0, count($arr) - 1); | |
while ($lo <= $hi) { | |
$mid = intval($lo + ($hi - $lo) / 2); | |
if ($key < $arr[$mid]) { | |
$hi = $mid - 1; | |
} elseif ($key > $arr[$mid]) { |
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
# 二分 | |
class Array | |
def binary_search (key) | |
lo, hi = 0, self.length - 1 | |
while lo <= hi | |
mid = lo + (hi - lo) / 2 | |
hi = mid - 1 if key < self[mid] | |
lo = mid + 1 if key > self[mid] | |
return mid if key == self[mid] | |
end |
NewerOlder