kikit
6/22/2016 - 10:31 AM

Binary Array Sorting

Binary Array Sorting

/*
http://ideone.com/DyeLPA
http://www.practice.geeksforgeeks.org/problem-page.php?pid=532
*/

#include <iostream>
using namespace std;

int main() {
	int t, n, x;
	cin >> t;
	while(t--){
		cin >> n;
		int zero = 0, one = 0;
		while(n--){
			cin >> x;
			if(x == 0) zero++;
			else one++;
		}
		for(int i=0; i<zero; i++)
			cout << 0 << (((i==zero-1) && one==0)? "\n" : " ");
		for(int i=0; i<one; i++){
			cout << 1;
			cout << ((i==one-1) ? "\n" : " ");
		}
	}
	return 0;
}