public static void main(String[] args) { // 输入n代表有n个正整数,接着输入n个正整数,接着输入k代表求和 Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[] = newint[n + 1]; for (int i = 1; i <= n; i++) a[i] = in.nextInt(); int key = in.nextInt(); map[][] jj = new map[n + 1][key + 1]; in.close(); for (int i = 0; i < n + 1; i++) for (int j = 0; j < key + 1; j++) { map haha = new map();//这一步一定需要,切记 jj[i][j] = haha; jj[i][j].i = 0; }
for (int i = 1; i <= n; i++) { for (int j = 1; j <= key; j++) { if (jj[i][j].i == key && jj[i][j].nums.size() > 1) { for (int t : jj[i][j].nums) System.out.print(t + " "); System.out.println(); }
} }
}
private static ArrayList<Integer> copy(ArrayList<Integer> nums) { ArrayList<Integer> aa = new ArrayList<Integer>(); for (int i : nums) aa.add(i); return aa; }
static class map { int i; ArrayList<Integer> nums = new ArrayList<Integer>(); //记录路径 }