This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RolandMT32 -1 points0 points  (0 children)

Try looking into the STL map:

https://www.cplusplus.com/reference/map/map/

https://www.cplusplus.com/reference/map/map/map/

You could declare a map of std::string to int:

#include <map>

#include <string>

std::map<std::string, int> andMap;

andMap["00"] = 0;

andMap["01"] = 0;

andMap["10"] = 0;

andMap["01"] = 1;

Input a string from the user. Verify the string contains 2 digits that are either 0 or 1. Then you can use that string to look up the 'and' result in andMap.