fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector<vector<bool> > hitBox, hitBox2;
  7. vector<bool> oneline(10, true);
  8. for(int i = 0; i < 15; ++i)
  9. hitBox.push_back(oneline);
  10.  
  11. hitBox2 = hitBox;
  12. for (int i = 1; i < hitBox.size() - 1; ++i) //i starts at 1 to avoid checking edge tiles, check is < height - 1 for same reason
  13. {
  14. for (int j = 1; j < hitBox[i].size() - 1; ++j)
  15. {
  16. if(hitBox[i][j])
  17. {
  18. if (hitBox[i - 1][j - 1] &&
  19. hitBox[i - 1][j] &&
  20. hitBox[i - 1][j + 1] &&
  21. hitBox[i][j - 1] &&
  22. hitBox[i][j + 1] &&
  23. hitBox[i + 1][j - 1] &&
  24. hitBox[i + 1][j] &&
  25. hitBox[i + 1][j + 1])
  26. hitBox2[i][j] = false;
  27. }
  28. }
  29. }
  30. for(int i = 0; i < hitBox2.size(); ++i)
  31. {
  32. for(int j = 0; j < hitBox2[i].size(); ++j)
  33. cout << (hitBox2[i][j] ? '1' : ' ');
  34. cout << endl;
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 3436KB
stdin
Standard input is empty
stdout
1111111111
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1        1
1111111111