Array of alternate +ve and -ve no.s
/*
http://ideone.com/9Qg1bP
http://www.practice.geeksforgeeks.org/problem-page.php?pid=444
*/
#include <iostream>
#include <limits.h>
using namespace std;
int main() {
// your code goes here
int t, n, x;
cin >> t;
while(t--){
cin >> n;
int pos[101]={INT_MAX}, neg[101]={INT_MAX};
int p=0, k=0;
while(n--){
cin >> x;
if(x >= 0)
pos[p++] = x;
else
neg[k++] = x;
}
int max = p;
if(k > max) max = k;
for(int i=0; i<max; i++){
if((pos[i] != INT_MAX) && i < p){
cout << pos[i];
cout << ((i==max) ? "\n" : " ");
}
if((neg[i] != INT_MAX) && i < k){
cout << neg[i];
cout << ((i==max) ? "\n" : " ");
}
}
cout << endl;
}
return 0;
}