Checking for a match in each element of a 2d vector

  2d-vector, c++, c++11, for-loop, tic-tac-toe

I’m creating text based TicTacToe in C++ and need to create a function that checks for a win.

Right now, I have a vector of all the moves player X has made:

std::vector<int> x_vector = {1, 2, 3, 5, 7};

I also have a 2d vector of win conditions:

std::vector<std::vector> > wins = {{1, 2, 3}, {4, 5, 6}, {7, 8, 8}};

In this case, each element of the wins vector represents a win condition. If player X ever has a combination of inputs in their vector that includes one of the win conditions, I’m trying to get a bool function to return true.

I’m new to C++ and coding in general, so all patience is appreciated, and the simpler the solution you can help me find the better.

Source: Windows Questions C++

LEAVE A COMMENT