• 16进制(字符串)转换成2进制(字符串)


    CString myProject::Convert16To2(CString strSource)
    {
       //转换成大写字母
       strSource.MakeUpper();
       CString strDest;
       for( int i = 0;i < strSource.GetLength();i++ )
       {
          if(strSource.GetAt(i) == '0')
            strDest += _T("0000");
          if(strSource.GetAt(i) == '1')
             strDest += _T("0001");
          if(strSource.GetAt(i) == '2')
             strDest += _T("0010");
          if(strSource.GetAt(i) == '3')
             strDest += _T("0011");
          if(strSource.GetAt(i) == '4')
             strDest += _T("0100");
          if(strSource.GetAt(i) == '5')
             strDest += _T("0101");
          if(strSource.GetAt(i) == '6')
             strDest += _T("0110");
          if(strSource.GetAt(i) == '7')
             strDest += _T("0111");
          if(strSource.GetAt(i) == '8')
             strDest += _T("1000");
          if(strSource.GetAt(i) == '9')
             strDest += _T("1001");
          if(strSource.GetAt(i) == 'A')
             strDest += _T("1010");
          if(strSource.GetAt(i) == 'B')

           strDest += _T("1011");
          if(strSource.GetAt(i) == 'C')
             strDest += _T("1100");
          if(strSource.GetAt(i) == 'D')
             strDest += _T("1101");
          if(strSource.GetAt(i) == 'E')
             strDest += _T("1110");
          if(strSource.GetAt(i) == 'F')
             strDest += _T("1111");
       }
       return strDest;
    }

  • 相关阅读:
    二分图模板(洛谷P3386)
    2013提高组复赛Day1
    2014Noip提高组复赛Day2题解
    Noip2016Day2T2 蚯蚓
    poj1655 Balancing Act
    codevs1919创世纪
    bzoj1040[ZJOI2008]骑士
    codevs1521 华丽的吊灯
    【20200414】ZumaV3-算法与数据结构课程作业
    【20171111】 Codevs 1214 线段覆盖
  • 原文地址:https://www.cnblogs.com/pbreak/p/1759562.html
Copyright © 2020-2023  润新知