package com.heima.stringbuffer;
public class Demo6_Num789 {
/**
* @param args
* (1)打印由7,8,9三个数组组成的三位数,要求该三位数中任意两位数字不能相同
(2)打印格式最后的三位数字以空格分隔,如789 798 9879 87 978 987
*/
public static void main(String[] args) {
char[] ch = {'7','8','9'};
StringBuffer sb = new StringBuffer();
//demo1(ch, sb, count, temp);
for (int i = 0; i < ch.length; i++) {
for (int j = 0; j < ch.length; j++) {
for (int j2 = 0; j2 < ch.length; j2++) {
if (i != j && j != j2 && i != j2) {
sb.append(ch[i]).append(ch[j]).append(ch[j2]).append(" ");
}
}
}
}
System.out.println(sb);
}
|
|