虫言虫语 虫言虫语

题目数量和分值固定的情况下抽取不同分值题型分布

in PHPread (21193) 文章转载请注明来源!
 public function sum()
{
    $sum = 0;
    $arr = array();

// 最大分值

    $max=6;

// 最小分值

    $min=1;

// 总分

    $sum_n = 40;

// 题目数量

    $n=10;
    for ($i=1;$i<$max+1;$i++){
        $list[$i]=0;
    }
    $i = 1;
    while ($i <=$n) {
        $a = rand($min, $max);
            if (($sum_n-$sum-$a)>=$min*($n-$i) && ($sum_n-$sum-$a)<=$max*($n-$i)) {
                $sum = $sum + $a;
                $list[$a]=$list[$a]+1;
                $arr[] = $a;
                $i++;
            }
    }
    $ss = 0;
    foreach ($arr as $a) {
        $ss = $ss + $a;
    }
    var_dump($list);
    var_dump($ss);
    dd($arr);
}
jrotty WeChat Pay

微信打赏

jrotty Alipay

支付宝打赏

文章二维码

扫描二维码,在手机上阅读!

PHP
发表新评论
已有 7594 条评论
  1. econcorenny
    econcorenny
    回复

    http://onlinecasinosgtx.com/ slots free world class casino slots online casino online casinos

  2. RafSeinaclecoca
    RafSeinaclecoca
    回复

    online casino slots http://onlinecasinosgtx.com/ - slots games cashman casino slots best online casinos

  3. SeapokeSmele
    SeapokeSmele
    回复

    online slots http://onlinecasinosgtx.com/ real money casino free slots games vegas slots online

  4. econcorenny
    econcorenny
    回复

    play casino online casinos online gambling no deposit casino http://onlinecasinosgtx.com/ - slots free

  5. econcorenny
    econcorenny
    回复

    play online casino big fish casino gold fish casino slots

  6. Nosepeds
    Nosepeds
    回复

    Kudos. A good amount of knowledge. cialis 20mg viagra sans ordonnance

  7. econcorenny
    econcorenny
    回复

    play online casino free slots games casino game slots for real money http://onlinecasinosgtx.com/ - vegas slots online

  8. RafSeinaclecoca
    RafSeinaclecoca
    回复

    casino play http://onlinecasinosgtx.com/ - slots online casino blackjack vegas slots online

  9. SeapokeSmele
    SeapokeSmele
    回复

    http://onlinecasinosgtx.com/ slots online http://onlinecasinosgtx.com/ - casino online play slots online

  10. MatExcupe
    MatExcupe
    回复

    Amoxicillin Capsules Types http://buycialisuss.com - Cialis Kamagra Hair Loss Cialis Cialis 5

  11. econcorenny
    econcorenny
    回复

    casino blackjack free casino slot games play casino casino bonus codes http://onlinecasinosgtx.com/ - slots free

  12. etenops
    etenops
    回复

    Beneficial knowledge. Thank you. cbd oil cost

  13. econcorenny

    big fish casino slots games cashman casino slots no deposit casino

  14. SeapokeSmele

    online gambling online casino slots play online casino

博客已萌萌哒运行
© 2020 由 Typecho 强力驱动.Theme by Yodu
前篇 后篇
雷姆
拉姆