虫言虫语 虫言虫语

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

in PHPread (59923) 文章转载请注明来源!
 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
发表新评论
已有 15284 条评论
  1. swimarumTauff
    swimarumTauff
    回复

    http://creditcheckmax.com/ check my credit report http://creditcheckmax.com/ - credit bureau credit score ratings

  2. crapyragacoup
    crapyragacoup
    回复

    social credit score get credit report check my credit score credit karma experian business credit report http://creditcheckweb.com/ - credit bureau

  3. AnnaDes
    AnnaDes
    回复

    generic toradol accutane price robaxin 1000 mg price buy anafranil online australia

  4. JimDes
    JimDes
    回复

    prednisone 20 benicar 20 mg cost where to buy prednisone online without a script

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