C++ equivalent of Python dictionaries

后端 未结 5 775
后悔当初
后悔当初 2021-02-14 06:42

I\'m currently making a tic-tac-toe program with AI and i\'m having a bit of a trouble translating this line of code (python) :

RANKS = dict([(4,3),                      


        
5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-14 07:13

    Although a "language equivalent" might me something like an std::unordered_map your use case may be more efficiently served with a straight array:

    int RANKS[] = {2, 1, 2, 1, 3, 1, 2, 1, 2};
    

提交回复
热议问题