[Cpp]
Description: crc Check question. Fortunately, I just learned it recently. Otherwise, it will not happen.
# Include <cstdio>
# Include <cstring>
Char str [1100];
Char t [] = {'0', '1', '2', '3', '4', '5', '6', '7 ', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F '};
Int main ()
{
// Freopen ("a.txt", "r", stdin );
Int len;
Long sum (g = 34943;
While (gets (str ))
{
Len = strlen (str );
If (len = 1 & str [0] = '#') break;
Sum = 0;
For (int I = 0; I <len; I ++)
Sum = (sum * 256 + str [I]) % g;
Sum = sum * 256 * 256% g;
Sum = g-sum;
If (sum = g) printf ("00 00 \ n ");
Else
{
Int arr [4];
For (int I = 3; I> = 0; I --)
{
Arr [I] = sum % 16;
Sum/= 16;
}
Printf ("% c \ n", t [arr [0], t [arr [1], t [arr [2], t [arr [3]);
}
}
Return 0;
}
Description: crc Check question. Fortunately, I just learned it recently. Otherwise, it will not happen.
# Include <cstdio>
# Include <cstring>
Char str [1100];
Char t [] = {'0', '1', '2', '3', '4', '5', '6', '7 ', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F '};
Int main ()
{
// Freopen ("a.txt", "r", stdin );
Int len;
Long sum (g = 34943;
While (gets (str ))
{
Len = strlen (str );
If (len = 1 & str [0] = '#') break;
Sum = 0;
For (int I = 0; I <len; I ++)
Sum = (sum * 256 + str [I]) % g;
Sum = sum * 256 * 256% g;
Sum = g-sum;
If (sum = g) printf ("00 00 \ n ");
Else
{
Int arr [4];
For (int I = 3; I> = 0; I --)
{
Arr [I] = sum % 16;
Sum/= 16;
}
Printf ("% c \ n", t [arr [0], t [arr [1], t [arr [2], t [arr [3]);
}
}
Return 0;
}