fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int A[]={0, 1, 0, 1, 0, 0, 1, 1, 1, 0};
  7. int size=sizeof(A)/sizeof(A[0]);
  8. int count=0;
  9. for(int i=0;i<size;i++)
  10. {
  11. if(A[i]==0)
  12. count++;
  13. }
  14. for(int i=0;i<count;i++)
  15. A[i]=0;
  16. for(int i=count;i<size;i++)
  17. A[i]=1;
  18. for(int i=0;i<size;i++)
  19. cout<<A[i]<<" ";
  20. cout<<endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 4312KB
stdin
Standard input is empty
stdout
0 0 0 0 0 1 1 1 1 1