3,7,8,9用加减乘除怎样能得出24
2019-06-17
展开全部
根据题意可知。
算式就是。
3×(7+9-8)=3×8=24,
一般是利用四六或三八二十四。
算式就是。
3×(7+9-8)=3×8=24,
一般是利用四六或三八二十四。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2019-06-17
展开全部
3,7,8,9用加减乘除怎样能得出24?
答:9-8=1
1+7=8
3×8=24
总体为:3×(9-8+7)=24
答:9-8=1
1+7=8
3×8=24
总体为:3×(9-8+7)=24
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
3×[9-8+7]=24.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
3 * (7 - 8 + 9)
下面是js代码:
<h4>3,7,8,9用加减乘除怎样能得出24?</h4>
<input type="text" id="text"/>
<script>
document.getElementById("text").value = "ssssss";
// a b c d
function seekExpression0() {
console.log('seekExpression0------------------------------>seekExpression0');
var a = 3, b = 7, c = 8, d = 9;
var jia = '+', jian = '-', cheng = '*', chu = '/';
var operater = [jia, jian, cheng, chu];
var expression = '';
for (var i = 0; i < 4; i++) {
var op0 = operater[i];
for (var j = 0; j < 4; j++) {
var op1 = operater[j];
for (var k = 0; k < 4; k++) {
var op2 = operater[k];
expression = 'a ' + op0 + ' b ' + op1 + ' c ' + op2 + ' d';
var jieguo = eval(expression) * 1;
console.log('expression:' + expression + ' = ' + jieguo);
console.log('');
if (jieguo === 24) {
return expression;
}
}
}
}
return 'NotFoundTheExpressiong';
}
// (a b) c d
// a (b c) d
// a b (c d)
// (a b c) d
// a (b c d)
function seekExpression1(bracketPosition) {
console.log('seekExpression1------------------------------>' + bracketPosition);
var a = 3, b = 7, c = 8, d = 9;
var jia = '+', jian = '-', cheng = '*', chu = '/';
var operater = [jia, jian, cheng, chu];
var expression = '';
for (var i = 0; i < 4; i++) {
var op0 = operater[i];
for (var j = 0; j < 4; j++) {
var op1 = operater[j];
for (var k = 0; k < 4; k++) {
var op2 = operater[k];
// (a b) c d
if (bracketPosition == 1) expression = '(a ' + op0 + ' b) ' + op1 + ' c ' + op2 + ' d';
// a (b c) d
if (bracketPosition == 2) expression = 'a ' + op0 + ' (b ' + op1 + ' c) ' + op2 + ' d';
// a b (c d)
if (bracketPosition == 3) expression = 'a ' + op0 + ' b ' + op1 + ' (c ' + op2 + ' d)';
// (a b c) d
if (bracketPosition == 4) expression = '(a ' + op0 + ' b ' + op1 + ' c) ' + op2 + ' d';
// a (b c d)
if (bracketPosition == 5) expression = 'a ' + op0 + ' (b ' + op1 + ' c ' + op2 + ' d)';
//
var jieguo = eval(expression) * 1;
console.log('expression:' + expression + ' = ' + jieguo);
console.log('');
if (jieguo === 24) {
return expression;
}
}
}
}
return 'NotFoundTheExpressiong';
}
var expressionOk = seekExpression0();
var bracketPosition = 1;
while (expressionOk == 'NotFoundTheExpressiong' && bracketPosition <= 5) {
expressionOk = seekExpression1(bracketPosition);
bracketPosition++;
}
console.log('expressionOk:' + expressionOk);
document.getElementById("text").value = expressionOk;
</script>
下面是js代码:
<h4>3,7,8,9用加减乘除怎样能得出24?</h4>
<input type="text" id="text"/>
<script>
document.getElementById("text").value = "ssssss";
// a b c d
function seekExpression0() {
console.log('seekExpression0------------------------------>seekExpression0');
var a = 3, b = 7, c = 8, d = 9;
var jia = '+', jian = '-', cheng = '*', chu = '/';
var operater = [jia, jian, cheng, chu];
var expression = '';
for (var i = 0; i < 4; i++) {
var op0 = operater[i];
for (var j = 0; j < 4; j++) {
var op1 = operater[j];
for (var k = 0; k < 4; k++) {
var op2 = operater[k];
expression = 'a ' + op0 + ' b ' + op1 + ' c ' + op2 + ' d';
var jieguo = eval(expression) * 1;
console.log('expression:' + expression + ' = ' + jieguo);
console.log('');
if (jieguo === 24) {
return expression;
}
}
}
}
return 'NotFoundTheExpressiong';
}
// (a b) c d
// a (b c) d
// a b (c d)
// (a b c) d
// a (b c d)
function seekExpression1(bracketPosition) {
console.log('seekExpression1------------------------------>' + bracketPosition);
var a = 3, b = 7, c = 8, d = 9;
var jia = '+', jian = '-', cheng = '*', chu = '/';
var operater = [jia, jian, cheng, chu];
var expression = '';
for (var i = 0; i < 4; i++) {
var op0 = operater[i];
for (var j = 0; j < 4; j++) {
var op1 = operater[j];
for (var k = 0; k < 4; k++) {
var op2 = operater[k];
// (a b) c d
if (bracketPosition == 1) expression = '(a ' + op0 + ' b) ' + op1 + ' c ' + op2 + ' d';
// a (b c) d
if (bracketPosition == 2) expression = 'a ' + op0 + ' (b ' + op1 + ' c) ' + op2 + ' d';
// a b (c d)
if (bracketPosition == 3) expression = 'a ' + op0 + ' b ' + op1 + ' (c ' + op2 + ' d)';
// (a b c) d
if (bracketPosition == 4) expression = '(a ' + op0 + ' b ' + op1 + ' c) ' + op2 + ' d';
// a (b c d)
if (bracketPosition == 5) expression = 'a ' + op0 + ' (b ' + op1 + ' c ' + op2 + ' d)';
//
var jieguo = eval(expression) * 1;
console.log('expression:' + expression + ' = ' + jieguo);
console.log('');
if (jieguo === 24) {
return expression;
}
}
}
}
return 'NotFoundTheExpressiong';
}
var expressionOk = seekExpression0();
var bracketPosition = 1;
while (expressionOk == 'NotFoundTheExpressiong' && bracketPosition <= 5) {
expressionOk = seekExpression1(bracketPosition);
bracketPosition++;
}
console.log('expressionOk:' + expressionOk);
document.getElementById("text").value = expressionOk;
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询