public class test4 {
public static void main(String[] args) {
/*(1)打印由7,8,9三个数组组成的三位数,要求该三位数中任意两位数字不能相同
(2)打印格式最后的三位数字以空格分隔,如789 798 879 897 978 987*/
String s = "";
for (int i = 7; i < 10; i++) {
for (int j = 7; j < 10; j++) {
for (int k = 7; k < 10; k++) {
if (i == k) {
continue;
}else if(i == j) {
continue;
}else if(j == k) {
continue;
}else {
int num = i*100 + j*10 + k;
s += num + " ";
}
}
}
}
System.out.println(s);
}
} |