62,614
社区成员
发帖
与我相关
我的任务
分享
package Test;
public class test {
public static void main(String[] args) {
for(int x1=1;x1<4;x1++){
for(int x2=1;x2<4;x2++){
for(int x3=1;x3<4;x3++){
for(int x4=1;x4<4;x4++){
for(int x5=1;x5<4;x5++){
for(int x6=1;x6<4;x6++){
s(x1,x2,x3,x4,x5,x6);
}
}
}
}
}
}
}
public static void s(int x1,int x2,int x3,int x4,int x5,int x6){
double sum = 8;
sum = s1(sum, x1);
sum = s1(sum, x2);
sum = s1(sum, x3);
sum = s1(sum, x4);
sum = s1(sum, x5);
sum = s1(sum, x6);
if (sum==200) {
System.out.println(8+" "+y(x1)+" "+8+" "+y(x2)+" "+8+" "+y(x3)+" "+8+" "+y(x4)+" "+8+" "+y(x5)+" "+8+" "+y(x6)+" "+8);
}
}
public static double s1(double sum,int x){
switch (x) {
case 1:
sum +=8;
break;
case 2:
sum -=8;
break;
case 3:
sum *=8;
break;
case 4:
sum /=8;
break;
}
return sum;
}
public static String y(int i){
switch (i) {
case 1:
return "+";
//break;
case 2:
return "-";
//break;
case 3:
return "*";
//break;
case 4:
return "/";
//break;
}
return null;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>弹出消息框</title>
<script type="text/javascript">
function show1(){
for(var x1=1;x1<=4;x1++){
for(var x2=1;x2<=4;x2++){
for(var x3=1;x3<=4;x3++){
for(var x4=1;x4<=4;x4++){
for(var x5=1;x5<=4;x5++){
for(var x6=1;x6<=4;x6++){
var str="8"+show(x1)+"8"+show(x2)+"8"+show(x3)+"8"+show(x4)+"8"+show(x5)+"8"+show(x6)+"8";
var sum = eval(str);
//总和等于多少
if(sum==200){
document.write(str+"="+eval(sum)+"<br />");
}
}
}
}
}
}
}
}
</script>
<script type="text/javascript">
function show(a){
switch (a) {
case 1:
return ("+");
//break;
case 2:
return ("-");
//break;
case 3:
return ("*");
//break;
case 4:
return ("/");
//break;
}
return null;
}
</script>
</head>
<body onload="show1()">
</body>
</html>