1 public static void main(String[] args) { 2 int x = 0; 3 for (int i = 0; i < 2; i++) { 4 System.out.println("compare i:" + i + " " + ++x); 5 for (int j = 0; j < 3; j++) { 6 System.out.println("compare j:" + j + " " + ++x); 7 for (int k = 0; k < 4; k++) { 8 System.out.println("compare k:" + k + " " + ++x);//i与2比较2次,j6次,k24次 9 } 10 } 11 } 12 13 System.out.println(); 14 x = 0; 15 16 for (int i = 0; i < 4; i++) { 17 System.out.println("compare i:" + i + " " + ++x); 18 for (int j = 0; j < 3; j++) { 19 System.out.println("compare j:" + j + " " + ++x); 20 for (int k = 0; k < 2; k++) { 21 System.out.println("compare k:" + k + " " + ++x);//i 4;j 12;k 24; 22 } 23 } 24 } 25 }
时间: 2024-10-27 02:33:44