Created
June 21, 2014 14:57
-
-
Save alexzhou/cee9d5352b468740f500 to your computer and use it in GitHub Desktop.
《编程珠玑》翻转字符串算法
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
<?php | |
function reverse($arr, $len, $m){ | |
$k = 0; | |
for($i = 0; $i < $m; $i++){ | |
$k = 1; | |
$temp = $arr[$i]; | |
while(($k*$m+$i) % $len != $i){ | |
$arr[($k-1)*$m+$i] = $arr[$k*$m+$i]; | |
$k++; | |
} | |
$arr[($k-1)*$m+$i] = $temp; | |
} | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Has php Notice about array offset