#include <iostream>
#include <limits>
struct space {
bool state;
};
struct grid {
int sizes;
space cell[100][100] { false }; // create 'cell' and set all values to false
void sSwitch(int x, int y)
{
cell[x][y].state = !cell[x][y].state;
}
int getmany()
{
int howmany = 0;
for(int x = 0; x < 100; x++) {
for(int y = 0; y < 100; y++) {
if(cell[x][y].state == true) {
howmany++;
}
}
}
return howmany;
}
};
void waitForEnter();
int main()
{
grid g;
g.cell[7][11].state = true;
g.cell[21][33].state = true;
std::cout << "There are currently " << g.getmany() << " cells set to true.\n";
g.sSwitch(21, 33);
std::cout << "Now there are " << g.getmany() << " cells set to true.\n";
g.sSwitch(99, 7); // from false to true
std::cout << "And now there are " << g.getmany() << " cells set to true again.\n";
waitForEnter();
return 0;
}
void waitForEnter()
{
std::cout << "\nPress ENTER to continue...\n";
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}