<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
/*
鸡兔同笼35个头94只脚, 鸡有多少只兔有多少只?
兔:x 0 1 2
鸡:y 35-0 35-1 35-2
x+y=35;
2x+4y=94;
*/
for (var x = 0; x <= 35; x++) {
if (2 * x + 4 * (35 - x) == 94) {
document.write("鸡:" + x + ",");
document.write("兔:" + (35 - x));
}
}
document.write("<br>");
//i:鸡
for (var i = 0; i <= 35; i++) {
for (var j = 0; j <= 35 - i; j++) {
if (i + j == 35 && 2 * i + 4 * j == 94) {
document.write("鸡:" + i + ",");
document.write("兔:" + j);
}
}
}
</script>
</body>
</html>