这是解压算法
year = readak[5] & 0x7f; month = readak[6] & 0x0f; day = (readak[5] >> 3 & 0xf0) | (readak[6] >> 4);
0x90 0x86 解压出来 17 06 24
0x11 0x31 解压出来 17 01 03
求这个代码的压缩算法
解决方案
100
你给的例子是不是写错了啊,0x90 0x86 应该和 16 06 24对应啊,假如是的话可以用下面的方法实现一一对应
#include "stdio.h" #include "string.h" #include "stdlib.h" int main() { short year = 17; short month = 1; short day = 3; short m1 = 0; short m2 = 0; //加密 m1 = 0x00 | year; m2 = 0x00 | month; m1 = (day&0x10)<<3 | m1; m2 = m2 | (day&0x0f)<<4; //解密 year = m1 & 0x7f; month = m2 & 0x0f; day = (m1 >> 3 & 0xf0) | (m2 >> 4); printf("%x, %x\n",m1, m2); printf("%d, %d, %d\n",year, month, day); // system("pause"); return 0; }