fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void Sort(int array[], int size);
  5.  
  6. int main()
  7. {
  8. const int size=10;
  9. int Arr[size]={1,1,0,0,1,0,1,0,0,0};
  10. Sort(Arr,size);
  11.  
  12. return 0;
  13. }
  14.  
  15. void Sort(int array[], int size)
  16. {
  17. for ( int i = 0, j = size-1; i < j; )
  18. {
  19. if ( array[i] != 0 && array[j] != 1 )
  20. {
  21. int temp;
  22. temp = array[j];
  23. array[j] = array[i];
  24. array[i] = temp;
  25. }
  26.  
  27. if ( array[i] == 0 ) i++;
  28. if ( array[j] == 1 ) j--;
  29. }
  30.  
  31. for(int i=0;i<size;i++)
  32. {
  33. cout<<array[i];
  34. }
  35. return;
  36. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
0000001111