fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8,9 };
  6. const size_t N = sizeof( arr ) / sizeof( *arr );
  7. for(auto x: arr) cout << x << " ";
  8. int a = 3, b = 6;
  9.  
  10. for(int i=0, j=0;i<N;){
  11. if(j<N){
  12. if(!(arr[j] >= a && arr[j] <=b)){
  13. i++;
  14. }
  15. arr[i]=++j<N? arr[j]:0;
  16. }
  17. else{
  18. arr[i++]=0;
  19. }
  20. }
  21. cout<<endl;
  22. for(auto x: arr) cout << x << " ";
  23. // your code goes here
  24. return 0;
  25. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5 6 7 8 9 
0 1 2 7 8 9 0 0 0 0