void convert(unsigned int code, char * plaintext)
{
/* 截取前后两个字母的密码 */
char letter0 = (char)(code >> 8), letter1 = (char)code;
/* 以0x61减去a的ASCII值(a的ASCII值是0x41),得到的差即是密码转换因数 */
char factor = 0x61 - ‘a’;
plaintext[1] = letter1 - factor;
plaintext[0] = letter0 - factor;
/* 打印要用%c格式,否则看到的就是数字 */
printf("the 2 letter is %c%c\n"
, plaintext[0]
, plaintext[1]);
}
5分真少。
追问分可以加! 我看一下先= = 有点没看懂。。。
追答由于你没有告诉我大写字母的密码,所以这个函数只能转换小写字母,而且超过z以后的数字可能会是乱码,你可以自己加范围判断。