摘要:<?phpclass double_link { public $name; public $next; public $prev; public function __construct($name) { $this->name = $name; }}function get_double_link($total) { $current = $first = new double_link(1); $pre = NULL; for ($i=2; $i < $total; $i++) { $current -> ne...
阅读全文
摘要:$arr = array(1,2,3,4,5,6)需求从$arr中选出任意多个元素的所有组合比如任选三,通常我们只需要用三个for循环,但是这并不能适合于所有情况,如果在要求得出所有任选四的所有组合,就必须再加四个for循环,如果再多呢?适用于任选n的所有情况:<?php//核心:采用堆+递归的形式实现function get_rx($target,$arr) { static $rzRzt = array(); $count = count($arr); $selfName = __FUNCTION__; global $n; if ($count<1)...
阅读全文
摘要:function award_sp_cal($spRzt) { $totalAward = 1; $temp = null; foreach($spRzt as $sp) { if (count($sp) == 1) { $totalAward *= array_shift($sp); } else if (count($sp) >1 ) { $temp = $totalAward; $totalAward = 0;//原理: a*x + b*x = (a+b)*x ...
阅读全文