fork(1) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. int t, n, a[100005], tmp;
  8. scanf("%d", &t);
  9. while(t--) {
  10. scanf("%d", &n);
  11. for(int i=0; i<n; i++) scanf("%d", &a[i]);
  12. sort(a, a+n);
  13. for(int i=1; i<n; i++) {
  14. if(i%2==0) {
  15. tmp=a[i];
  16. a[i]=a[i-1];
  17. a[i-1]=tmp;
  18. }
  19. }
  20. for(int i=0; i<n; i++) printf("%d ", a[i]);
  21. printf("\n");
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 3612KB
stdin
2
2
3 2
3
10 5 2
stdout
2 3 
2 10 5