Simple dictionary in C++

前端 未结 8 1078

Moving some code from Python to C++.

BASEPAIRS = { \"T\": \"A\", \"A\": \"T\", \"G\": \"C\", \"C\": \"G\" }

Thinking maps might be overkill? W

8条回答
  •  伪装坚强ぢ
    2021-01-30 16:59

    Here's the map solution:

    #include 
    #include 
    
    typedef std::map BasePairMap;
    
    int main()
    {
        BasePairMap m;
        m['A'] = 'T';
        m['T'] = 'A';
        m['C'] = 'G';
        m['G'] = 'C';
    
        std::cout << "A:" << m['A'] << std::endl;
        std::cout << "T:" << m['T'] << std::endl;
        std::cout << "C:" << m['C'] << std::endl;
        std::cout << "G:" << m['G'] << std::endl;
    
        return 0;
    }
    

提交回复
热议问题