请输入头数:<input type="text" id="head"/><br/><br/><br/>
请输入脚数:<input type="text" id="foot"/><br/><br/><br/>
<input type="submit" id="sub"/>
<p id="ji"></p>
<p id="tu"></p>
</body>
<script>
var input1=document.getElementById("head")
var input2=document.getElementById("foot")
var sub=document.getElementById("sub")
var ji=document.getElementById("ji")
var tu=document.getElementById("tu")
sub.onclick=function(){
var txt1=input1.value
var txt2=input2.value
for(var i=1i<txt1i++){
if(i*2+(txt1-i)*4==txt2){
ji.innerText="鸡有"+i+"只"
tu.innerText="兔有"+(txt1-i)+"只"
}
}
}
</script>
Sub adsf() Dim n%, m%, TS%, JS% 5: n = InputBox("请输入总的个数:") If n = 0 Then GoTo 5 10: m = InputBox("请输入总的脚数:") If m = 0 Or m Mod 2 <>0 Or m <2 * n Then MsgBox "输入脚数不合理,请重新输入:", vbOKOnly + 64 GoTo 10 End If TS = (m - 2 * n) / 2 JS = (4 * n - m) / 2 If TS <0 Or JS <0 Or TS + JS <>n Or 4 * TS + 2 * JS <>m Then GoTo 10 MsgBox "鸡有:" &JS &"只" &Chr(13) &"兔有:" &TS &"只" End Sub