Requirement: All rewards including level 5 equipment can only be claimed after clearing 10234567.
premise:
The ID rules of the game are as follows:
Length: 8 decimal digits, such as 12345678
The first 2 digits represent the ID type, for example, 10 represents the level ID, 11 represents the equipment ID, and 12 represents the item ID;
Where for a gear ID: 11 2 34 567
2 means quality;
34 indicates the location;
567 means level;
solution:
Method 1: The easiest for programmers is to let the game planner configure all level 5 equipment in the table, and their unlocked levels are all 10234567;
Disadvantage : With this limitation alone, a maximum of 999,999 records need to be filled in for planning, so the search performance and memory usage are both a problem for the program ;
For practitioners who don't understand programs, filling in the pattern matching template in decimal digits is an easy-to-understand method.
The code of the comparison function to find and sort is as follows:
//Recursive call, first high bit, then low bit //Compare by decimal digits, if it is 0, ignore the current digit, static inline int DecimalBitCompare(uint32_t dwA, uint32_t dwB) { //compare single digits //dwA and dwB are both single digits if (dwA / 10 == 0 &&dwB/10 == 0) { if(dwA != 0 && dwB != 0) { return dwA - dwB; } return 0; } // compare high int iHighResult = DecimalBitCompare (dwA / 10, dwB / 10); if(iHighResult == 0) { //The high bits are the same, then the low bits are compared return DecimalBitCompare(dwA%10, dwB%10); } return iHighResult; }