文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>计算排列组合的php代码

计算排列组合的php代码

时间:2008-05-17  来源:剑心通明


一段计算排列组合的
[url=javascript:;]代码[/url]

array("Student10", "Student11"),
                    2 => array("Student20", "Student21", "Student22"),
                    3 => array("Student30"),
                    4 => array("Student40", "Student41", "Student42", "Student43"));
/* 计算C(a,1) * C(b, 1) * ... * C(n, 1)的值 */
$CombineCount = 1;
foreach($CombinList as $Key => $Value)
{
    $CombineCount *= count($Value);
}
$RepeatTime = $CombineCount;
foreach($CombinList as $ClassNo => $StudentList)
{
    // $StudentList中的元素在拆分成组合后纵向出现的最大重复次数
    $RepeatTime = $RepeatTime / count($StudentList);
    $StartPosition = 1;
    // 开始对每个班级的学生进行循环
    foreach($StudentList as $Student)
    {
        $TempStartPosition = $StartPosition;
        $SpaceCount = $CombineCount / count($StudentList) / $RepeatTime;
        for($J = 1; $J ";
print_r($Result);
?>


相关阅读 更多 +
排行榜 更多 +
试着飞手游下载

试着飞手游下载

休闲益智 下载
血染小镇(功能菜单)中文版下载

血染小镇(功能菜单)中文版下载

飞行射击 下载
泰坦之旅高爆版下载

泰坦之旅高爆版下载

角色扮演 下载