洗牌问题
“`
package function;
import java.util.Scanner;
/**洗牌问题
* Create by ~JH~ on 2018/4/12
*/
public class Main_2 {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
int sum = sca.nextInt();
while (sum– > 0) {
int n = sca.nextInt();
int k = sca.nextInt();
int res[] = new int[2 * n];
for (int i = 0; i < 2 * n; i++) {
int temp = i + 1;
for (int j = 0; j < k; j++) {
if (temp <= n) {
temp = 2 * (temp) - 1;
} else {
temp = 2 * (temp - n);
}
}
res[temp - 1] = sca.nextInt();
}
for (Integer i : res
) {
System.out.print(i + ” “);
}
System.out.println();
}
}
}
```