C++ map遍歷


#include "stdio.h"
#include "string.h"
#include "string"
#include "iostream"
#include "math.h"
#include "map"
using namespace std;
map<char,string> mp;
map<char,string>::iterator it;
int main(int argc, char const *argv[])
{
  mp[
'0']="0000";mp['1']="0001";mp['2']="0010";
  mp['3']="0011";mp['4']="0100";mp['5']="0101";
  mp['6']="0110";mp['7']="0111";mp['8']="1000";
  mp['9']="1001";mp['A']="1010";mp['B']="1011";
  mp['C']="1100";mp['D']="1101";mp['E']="1110";   mp['F']="1111"; for(it = mp.begin(); it != mp.end(); it++) cout<<it->first<<":"<<it->second<<endl;
     //it->first下標的值,it->second所在下標的值 return 0; }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM