Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct cell
- {
- bool full;
- int near;
- int generation;
- cell()
- :full(false), near(0), generation(0) { };
- cell(bool full)
- :full(full), near(0), generation(0) { };
- void NearCellStatusChanged(bool status)
- {
- if (status == true)
- near++;
- else near--;
- if (near == 3)
- {
- full = true;
- generation++;
- }
- }
- void change_status(bool full_, cell c[][100], int row, int col) //
- {
- full = full_;
- for (int q = -1; q < 2; q++)
- {
- for (int q2 = -1; q2 < 2; q2++)
- {
- if (q == 0 && q2 == 0) //this element
- q2++;
- c[row + q][col + q2].NearCellStatusChanged(full_);
- }
- }
- }
- void delete_check(cell cells[][100], int row, int col)
- {
- if (this->near < 2 || this->near > 3)
- this->change_status(false, cells, row, col);
- }
- };
- int main()
- {
- int row[100], col[100];
- cell cells[100][100];
- int i = 0;
- for (i; cin; i++)
- {
- cout << "row: ";
- cin >> row[i];
- cout << endl;
- cout << "col: ";
- cin >> col[i];
- cout << endl;
- cells[row[i]][col[i]].change_status(true, cells, row[i], col[i]);
- }
- for (int q = 0; q < i; q++)
- cells[row[q]][col[q]].delete_check(cells, row[q], col[q]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement