没有jq币。。。。。哪位大好人发给我一份呗,QQ2443525105.谢谢啦
请问添加奖品奖项,角度怎么算的,有谁告诉我为什么是这几个角度:[26, 88, 137, 185, 235, 287, 337]
如果奖品添加到了9个怎么办?求解答?
//概率算法 function get_rand($arr) { $result = ""; $prosum = array_sum($arr); //计算总精度 foreach($arr as $key => $val): //$val 概率数 $randnum = mt_rand(1, $prosum); if ($randnum <= $val) { $result = $key; } else { $prosum -= $val; //如果值是50 下次几率很大 } endforeach; unset($arr); return $result; } //模拟一把 $prize_arr = array('0' => array('id' => 1, 'prize' => '平板电脑', 'v' => 1), '1' => array('id' => 2, 'prize' => '音响', 'v' => 5), '2' => array('id' => 3, 'prize' => '老人机', 'v' => 10), '3' => array('id' => 4, 'prize' => '手电', 'v' => 12), '4' => array('id' => 5, 'prize' => '风扇', 'v' => 22), '5' => array('id' => 6, 'prize' => '再来一次', 'v' => 50)); foreach($prize_arr as $val): $arr[$val['id']] = $val['v']; endforeach; $rid = get_rand($arr); //获取中奖ID $res['yes'] = $prize_arr[$rid - 1]['prize']; unset($prize_arr[$rid - 1]); shuffle($prize_arr); for ($i = 0; $i < count($prize_arr); $i++) { $re[] = $prize_arr[$i]['prize']; } $res['no'] = $re; var_dump(json_encode($res, JSON_UNESCAPED_UNICODE));
请问下怎么后台控制概率啊?
function get_rand($arr) { $result = ""; $prosum = array_sum($arr); //计算总精度 foreach($arr as $key => $val): //$val 概率数 $randnum = mt_rand(1, $prosum); if ($randnum <= $val) { $result = $key; } else { $prosum -= $val; //如果值是50 下次几率很大 } endforeach; unset($arr); return $result; } //模拟一把 $prize_arr = array('0' => array('id' => 1, 'prize' => '平板电脑', 'v' => 1), '1' => array('id' => 2, 'prize' => '音响', 'v' => 5), '2' => array('id' => 3, 'prize' => '老人机', 'v' => 10), '3' => array('id' => 4, 'prize' => '手电', 'v' => 12), '4' => array('id' => 5, 'prize' => '风扇', 'v' => 22), '5' => array('id' => 6, 'prize' => '再来一次', 'v' => 50)); foreach($prize_arr as $val): $arr[$val['id']] = $val['v']; endforeach; $rid = get_rand($arr); //获取中奖ID $res['yes'] = $prize_arr[$rid - 1]['prize']; unset($prize_arr[$rid - 1]); shuffle($prize_arr); for ($i = 0; $i < count($prize_arr); $i++) { $re[] = $prize_arr[$i]['prize']; } $res['no'] = $re; var_dump($res);
我下载测试的时候,canvas上添加的图片和文字在移动端出先了模糊的问题,百度后尝试画布放大2倍,再用样式恢复原始大小,结果还是模糊,请问楼主有遇到这个问题嘛?