解题思路:
import java.util.Arrays; import java.util.Scanner; public class C1218 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt(); for(int i = 0; i < n; i++){ int[] a = new int[4]; for(int j = 0; j < 4; j++){ a[j] = sc.nextInt(); } F(a); if(i < n-1) System.out.println(); } } sc.close(); } private static void F(int[] a){ //Arrays.sort(a); int rs = 0, count = 0; for(int i = 0; i < 4; i++){ for(int j = 0; j < 4; j++){ if(j != i){ for(int k = 0; k < 4; k++){ if(k != i && k != j){ for(int m = 0; m < 4; m++){ if(m != i && m != j && m != k){ rs = 1000*a[i] + 100*a[j] + 10*a[k] + a[m]; if(++count % 6 == 0) System.out.printf("%d\n", rs); else System.out.printf("%d ", rs); } } } } } } } } }
注意事项:
参考代码:
0.0分
0 人评分