fork(9) download
  1. #include <map>
  2.  
  3. struct monster
  4. {
  5. int Damage;
  6. int PowerUp;
  7. int Monster_Strength;
  8. int hp;
  9. int lvl;
  10. int money;
  11. int defense;
  12. };
  13.  
  14.  
  15. using key = std::pair<int,int> ; // dungeon_level,moster_level pair
  16.  
  17. // or typedef std::pair<int,int> key ; // C++98
  18.  
  19. std::map< key, monster > look_up =
  20. {
  21. { { 1, 1 } /* key */, { 23, 2, 5, 8, 19, 7, 9 } /* monster 1,1*/ },
  22. { { 1, 2 } /* key */, { 5, 7, 15, 2, 8, 15, 6 } /* monster 1,2*/ },
  23. { { 3, 5 } /* key */, { 1, 3, 11, 9, 17, 6, 1 } /* monster 3,5*/ },
  24. };
  25.  
  26. #include <iostream>
  27.  
  28. std::ostream& operator << ( std::ostream& stm, const key& k )
  29. { return stm << '(' << k.first << ',' << k.second << ')' ; }
  30.  
  31. std::ostream& operator << ( std::ostream& stm, const monster& m )
  32. {
  33. return stm << "monster{" << m.Damage << ',' << m.PowerUp << ',' << m.Monster_Strength
  34. << ',' << m.hp << ',' << m.lvl << ',' << m.money << ',' << m.money << '}' ;
  35. }
  36.  
  37. int main()
  38. {
  39. key k = { 1, 2 } ;
  40. std::cout << k << '\n' ;
  41.  
  42. for( const auto& p : look_up )
  43. std::cout << "key: " << p.first << " => data: " << p.second << '\n' ;
  44. }
  45.  
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
(1,2)
key: (1,1) => data: monster{23,2,5,8,19,7,7}
key: (1,2) => data: monster{5,7,15,2,8,15,15}
key: (3,5) => data: monster{1,3,11,9,17,6,6}