虫言虫语 虫言虫语

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

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

    canadian pharmacies viagra [url=http://canadianpharmonlinestore.com/cialis/]london pharmacy canada[/url] canada pharmacy cialis canada pharmacy viagra cialis-canadian pharmacy bdszpd
    buy cialis from us pharmacy

  2. euktbrszbglz
    euktbrszbglz
    回复

    online pharmacies canada viagra online pharmacy canadian online pharmacy generic cialis canada pharmacy
    canadian pharmacy-viagra cialis coupon for pharmacy cialis at canadian pharmacies canadian pharmacy.reviews
    buy viagra online canada pharmacy viagra india pharmacy best online pharmacies canada pharmacy online viagra canadian pharmacy online viagra

  3. https://abcviag.com/

    can i buy viagra from tesco
    viagra 75 mg
    soft cialis generic roani Cloup

  4. https://abcviag.com/

    generic medicine viagra
    best viagra online pharmacy
    buy viagra toronto online roani Cloup

  5. Pay For Essay Online

    compare and contrast essay college level help with accounting homework classification essay

  6. HjuaBronup
    HjuaBronup
    回复

    cheapest place to buy levitra can i buy levitra at walmart generic propecia price best propecia prices synthroid pills online how can i get synthroid

  7. JimDes
    JimDes
    回复

    famvir prescription cialis 20mg price australia cheap clomid for sale orlistat online canada get viagra online

  8. HjuaBronup
    HjuaBronup
    回复

    levitra online pharmacy buy levitra in usa buy propecia online canada propecia 5mg online cost of synthroid at costco what i should buy with synthroid

  9. JaneDes
    JaneDes
    回复

    generic prozac online

  10. amica auto insurance

    best quote auto insurance the general auto insurance erie insurance

  11. LouisBotdo
    LouisBotdo
    回复

    us pharmacy cialis canadian pharcharmy online without prescription cialis pharmacy online pharmacy without a prescription
    buy viagra from canada pharmacy canada pharmacy online pharmacy rx one 60 mg cialis canadian pharmacies shipping to usa
    canadian online pharmacy viagra canadian viagra online pharmacy reviews canadian rx pharmacy northwestern pharmacy canada generic pharmacy india

  12. sgkoodsvcchd
    sgkoodsvcchd
    回复

    pharmaceuticals from canada cialis-canadian pharmacy buy viagra online canada pharmacy www.northwestpharmacy.com viagra online pharmacy wdgmip
    canadian online pharmacy viagra

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