本帖最后由 海划时代 于 2015-12-5 17:35 编辑
- /**
- * 求一个四位数的重新排序,如4321改成1234,该如何完成
- */
- private static int all = 0;
- public static void main(String[] args) {
- for (int i = 1; i <= 4; i++) {
- for (int j = 1; j <= 4; j++) {
- for (int j2 = 1; j2 <= 4; j2++) {
- if (i != j && i != j2 &&j != j2) {
- System.out.print(i * 100 + j * 10 + j2 + " ");
- all++;
- }
- }
- }
- }
- System.out.println("总数为:" + all);
- }
复制代码
|