zoukankan      html  css  js  c++  java
  • 123

    void chToInt(char t, unsigned int & tt)
    {
    switch (t)
    {
    case '0':
    tt = 0;
    break;
    case '1':
    tt = 1;
    break;
    case '2':
    tt = 2;
    break;
    case '3':
    tt = 3;
    break;
    case '4':
    tt = 4;
    break;
    case '5':
    tt = 5;
    break;
    case '6':
    tt = 6;
    break;
    case '7':
    tt = 7;
    break;
    case '8':
    tt = 8;
    break;
    case '9':
    tt = 9;
    break;
    case 'a':
    tt = 10;
    break;
    case 'b':
    tt = 11;
    break;
    case 'c':
    tt = 12;
    break;
    case 'd':
    tt = 13;
    break;
    case 'e':
    tt = 14;
    break;
    case 'f':
    tt = 15;
    break;
    default:
    break;
    }
    }

    void IntToChar(unsigned int t, char & tt)
    {
    switch (t)
    {
    case 0:
    tt = '0';
    break;
    case 1:
    tt = '1';
    break;
    case 2:
    tt = '2';
    break;
    case 3:
    tt = '3';
    break;
    case 4:
    tt = '4';
    break;
    case 5:
    tt = '5';
    break;
    case 6:
    tt = '6';
    break;
    case 7:
    tt = '7';
    break;
    case 8:
    tt = '8';
    break;
    case 9:
    tt = '9';
    break;
    case 10:
    tt = 'a';
    break;
    case 11:
    tt = 'b';
    break;
    case 12:
    tt = 'c';
    break;
    case 13:
    tt = 'd';
    break;
    case 14:
    tt = 'e';
    break;
    case 15:
    tt = 'f';
    break;
    default:
    break;
    }
    }

    int main()
    {
    int num = 0;
    cin >> num;
    string mystr = " ";
    getline(cin, mystr);

    int i = 0;
    vector<string> strVec;
    while (i < num)
    {
    string strbuf;
    getline(cin, strbuf);
    strVec.push_back(strbuf);
    i ++;
    }

    for (int j = 0; j < strVec.size(); j++)
    {
    string em = strVec[j];
    int emSize = em.size();
    string tmp;
    for (int k = (emSize - 1); k >= 0; k--)
    {
    char t = em[k];
    unsigned int tt = 0;
    chToInt(t, tt);
    unsigned char aftertt = 0;
    for (int n = 3; n >= 0; n--)
    {
    aftertt = (aftertt | (((tt >> n) & 0x01) << (3 - n)));
    }
    aftertt = (~aftertt) & 0x0F;
    char afterChar;
    IntToChar(aftertt, afterChar);
    tmp = tmp + afterChar;
    }
    printf("%s ", tmp.c_str());
    }

    return 0;
    }

  • 相关阅读:
    带提示范围的猜数小游戏--python
    python中字符串的常见操作
    html表单相关标签及属性
    CSS常用属性
    python装饰器
    python闭包的概念及使用
    nuxt.js实战踩坑记录
    vuex填坑记录
    prerender-spa-plugin预处理vue项目实践
    node+express第一次实战踩坑记录
  • 原文地址:https://www.cnblogs.com/weiyouqing/p/12758320.html
Copyright © 2011-2022 走看看