Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sort array of 0's and 1's
//g++ 5.4.0 #include <iostream> using namespace std; void swap(int &x, int &y){ int temp = y; y = x; x = temp; } int main() { int arr[] = {0,1,1,0,0,0,1,0,1,0,0,0,1,1,0,1,0,1}; int z = sizeof(arr)/sizeof(arr[0]); int l, h; l = 0; h = z-1; while(l < h){ switch(arr[l]){ case 0: l++; break; case 1: swap(arr[l] , arr[h--]); break; } } for(auto x: arr){ cout << x << " " ; } }
run
|
edit
|
history
|
help
0
For Hello World
Kishan_Basic_Geometry
HashConPar
NameTempSpecial2
Vector+-OpLoad
Test1
TREE - path from root to leaf with given sum
substring search
DailyGroceryHisto
a ko z and z ko n string printing