fork(1) download
  1. #include <cstdio>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5. int main(){
  6. unsigned int t,n,x,z;
  7. bool l;
  8. string b;
  9. scanf("%d",&t);
  10. while(t--){
  11. l=true;
  12. b="";
  13. scanf("%d",&n);
  14. z=n;
  15. while(n--){
  16. if(l==true){
  17. scanf("%s",&x);
  18. b+=x;
  19. if(z%2==0)
  20. if(n!=1)
  21. b+=" ";
  22. if(z%2==1)
  23. if(n!=0)
  24. b+=" ";
  25. l=false;
  26. }
  27. else{
  28. scanf("%d",&x);
  29. cout<<x<<" ";
  30. l=true;
  31. }
  32. }
  33. cout<<b<<endl;
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0s 2820KB
stdin
2 
4 111 211 311 511
3 922 822 722 
stdout
211 511 1 3
822 9 7