package JAVA2013高职;
public class 奇怪的比赛之十层循环做法 {
public static void main(String[] args) {
// StringBuilder sb = new StringBuilder();
// int score = 10;
for(int a = 0; a<=1; a++){
for(int b = 0; b<=1; b++){
for(int c = 0; c<=1; c++){
for(int d = 0; d<=1; d++){
for(int e = 0; e<=1; e++){
for(int f = 0; f<=1; f++){
for(int g = 0; g<=1; g++){
for(int h = 0; h<=1; h++){
for(int i = 0; i<=1; i++){
for(int j = 0; j<=1; j++){
StringBuilder sb = new StringBuilder();
sb.append(a).append(b).append(c)
.append(d).append(e).append(f).append(g).append(h)
.append(i).append(j);
String answer= sb.toString();
// System.out.println(answer);
int score = 10;
for(int index = 0 ; index <= 9 ; index ++){
char ch = answer.charAt(index);
if(ch=='0'){
score=score-(index+1);
}else{
score=score*2;
}
}
if(score==100)System.out.println(answer);
}
}
}
}
}
}
}
}
}
}
}
}
运行结果:
0010110011
0111010000
1011010000