fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, const char * argv[])
  7. {
  8. int a[30];
  9. for(int i = 0; i < 30; ++i) a[i] = rand()%10;
  10.  
  11.  
  12. for(int i = 0; i < 30; ++i) cout << a[i] << " "; cout << endl;
  13.  
  14.  
  15. int j = 0;
  16. for(int i = 0; i < 30; ++i)
  17. {
  18. if (a[i] != 1) if (i != j) a[j++] = a[i];
  19. }
  20.  
  21. for(int i = 0; i < j; ++i) cout << a[i] << " "; cout << endl;
  22.  
  23. }
  24.  
  25.  
Success #stdin #stdout 0s 4488KB
stdin
Standard input is empty
stdout
3 6 7 5 3 5 6 2 9 1 2 7 0 9 3 6 0 6 2 6 1 8 7 9 2 0 2 3 7 5 
6 7 5 3 5 6 2 9 2 7 0 9 3 6 0 6 2 6 8 7 9 2 0 2 3 7 5