JavaScript Base instance: How to calculate 24 points (1)

Source: Internet
Author: User
Tags expression
<title>24 Point </title>
<meta name= "Author" content= "dlpower@163.com" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

<body>
<br>
Compute 24 Dots (add, subtract, multiply, divide, bracket) JavaScript version v1.0<br><br>
Author: <a href= ' mailto:dlpower@163.com ' >dlpower@163.com</a> (please specify author) <br><br>


2004-04-26 <br><br><br><br>
<form>
Please enter four digits (1-13):<br><br>
<input type= "text" name= "FA" size= "2" >
<input type= "text" name= "FB" size= "2" >
<input type= "text" name= "FC" size= "2" >
<input type= "text" name= "FD" size= "2" >
<br><br><input type= "button" Name= "btn" value= "calculation" >
</form>
<br><br>
<br><br>
In a deck of cards (52), the arbitrary extraction of 4 sheets can have 1820 different combinations, of which 458 are not 24 points.
<br><br>
The mid 1980s, Sun Shijie from Shanghai to the United States to settle. Sun Shijie A few of the neighbors are Americans. Neighbor's <br>
Child to his house, he had no other toys for the children to play, Brainwave, took out a pair of poker to teach them <br>
Play "24 points". Who knows, this play, unexpectedly make American children are fascinated. These kids bring this game home again and <br>
School, it was found that the game was very useful for developing intelligence, which was later promoted throughout the United States.

<script language= "JavaScript" >
function log (str)
{
document.write ("<br>" +str);
}

Generate a calculation expression
function Genexpress (EXP,A,B,C,D,M1,M2,M3)
{
var exp=exp.replace ("A", a);
Exp=exp.replace ("B", b);
Exp=exp.replace ("C", c);
Exp=exp.replace ("D", D);
Exp=exp.replace ("M1", M1);
Exp=exp.replace ("M2", m2);
Exp=exp.replace ("M3", m3);
return exp;
}


var answer = new Array ()//Expression of correct answer
var counter = number of 0;//answers

Test expression is correct



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.