fork download
  1. int main(void){
  2. int a[]={0, 0, 0, 0, 0, 0, 0};
  3. int n = 7,
  4. i,
  5. index = 0;
  6.  
  7. while(index < n && a[index]) index++; // skip initial 1's
  8. for(i = index; i < n; i++){
  9. if(a[i]) a[index++] = 1;
  10. a[i] = 0;
  11. }
  12.  
  13. for(i = 0; i < n; i++){
  14. printf("%3d", a[i]);
  15. }
  16. return 1;
  17. }
Runtime error #stdin #stdout 0s 1832KB
stdin
Standard input is empty
stdout
  0  0  0  0  0  0  0