C++ equivalent of Python dictionaries

后端 未结 5 773
后悔当初
后悔当初 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条回答
  •  野性不改
    2021-02-14 07:08

    In C++ this would be a std::unordered_map

    #include 
    
    std::unordered_map dict
    {
        {
            { 4, 3 },
            { 0, 2 }, { 2, 2 }, { 6, 2 }, { 8, 2 },
            { 1, 1 }, { 3, 1 }, { 5, 1 }, { 7, 1 }
        }
    };
    

提交回复
热议问题