JS 公鸡2文一只、母鸡1文一只、小鸡0.5文一只若一共有100文钱买100只鸡有多少种方法

读立写生 2018-04-12

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
    </body>
</html>
<script type="text/javascript">
    var biao = 0
    for(var i = 1;i < 50;i++){
        for(var j = 1;j<99;j++){
            for(var x = 1;x <= 98;x++){
                if(i*2 + j*1 + 0.5*x == 100 && i + j + x == 100){
                    biao++;
                    console.log(i+","+j+","+x);
                }
            }
        }
    }
    alert(biao)
</script>

相关推荐