用javascript编写“24点”游戏[2]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 yanwl 的 blog

function calcard(stack,cards,oper)
{
 if (stack.length < 2)
 {
  return;
 }
 steps.push(oper);
 calcul(stack,oper);
 playcards(stack, cards);
 steps.pop(oper);
}

function play()
{
 var stack = new array();
 var cards = new array();
 result.value = "";
 resultset.length = 0;
 for (var i = 0; i < icards.length; i++)
 {
  if (icards[i].value == "" || isnan(icards[i].value))
  {
   alert('输入格式不正确');
   icards[i].focus();
   return false;
  }
  cards.push(icards[i].value);
 }
 
 playcards(stack, cards);
 result.value += resultset.tostring();
}
</script>
<body>
         <br/>
 <input id = 'icards' style='width:80px'/>
 <input id = 'icards' style='width:80px'/>
 <input id = 'icards' style='width:80px'/>
 <input id = 'icards' style='width:80px'/>
 <input type='button' value='计算' onclick="play();"/><br/><br/>
 计算结果:<br/>
 <textarea id = 'result' style='width:440px;height:200px'></textarea>
</body>
</html>

本文关键:用javascript编写“24点”游戏
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top