Pre {Line-Height: 1; color: #800080; Background-color: # c0dcc0; font-size: 16px ;}. sysfunc {color: #000080; font-style: italic; font-weight: bold ;}. selffuc {color: #901d36 ;}. bool {color: # f70483 ;}. condition {color: #000080; font-weight: bold ;}. key {color: #800080 ;}. vaR {color: #800000; font-style: italic ;}. digit {color: # 68084f; font-weight: bold ;}. includepre {color: #800080 ;}. operator? {Color: # ff00ff; font-weight: bold ;}
Ing? A1------A20
??????????????B1------B20??????????????。。。??????????????Z1------Z20
This form
?
Number starting from 0:
Then :?? 0----19 ??? Corresponding ?? A1-----A20
?????????? 20---39 ?? Corresponding? B1-----B20 ?????????? # Define? Char_num? 20 ???????? Int ?? Nindex = 300 ;??????????? //? Sure? I ?? In? 0-----char_num * 26-1? Between ???????? Int? I = nindex % (char_num * 26 );???????? // The letter or digit corresponding to the number? ? Before the letter corresponding to this number, there are ncharposition letters ,? The letter at this position is :? 0x41 + ncharposition ???????? Int ?? Ncharposition =? I/char_num ;????????????? // Digit corresponding to the number ?? The value range is [1, char_num ]???????? Int? Nnum = I % char_num + 1 ;??????
???? # Define? Char_num? 20 ???????????? Int ?? Nindex = 300 ;???????????? //? Sure? I ?? In? 0-----char_num * 26-1? Between ?????? Int? I = nindex % (char_num * 26 );?????? // The letter or digit corresponding to the number? ? Before the letter corresponding to this number, there are ncharposition letters ,? The letter at this position is :? 0x41 + ncharposition ?????? Int ?? Ncharposition =? I/char_num ;?????? Char? P = 0x41 + ncharposition ;???????????? // Digit corresponding to the number ?? The value range is [1, char_num ]?????? Int? Nnum = I % char_num + 1 ;???? Number starting from 1 ?? :?
Then :?? 1----20 ??? Corresponding ?? A1-----A20
?????????? 21---40 ?? Corresponding? B1-----B20?
The above code starts from 0 ,?? At this time, the number starts encoding from 1. How do I modify the program?
Because? 1----20 ??? Corresponding ?? A1-----A20
?????????? 21---40 ?? Corresponding? B1-----B20
The rule is hard to find ,?? Therefore, we need to think of a method that uses the previous rule and can start encoding from 1.
?
Method:
??????? 1 )? Match the number first
1---20 ??? Corresponding to 0---19 ???
??????? 2 )? Then apply the last program ?? Convert 0-19 ?? Corresponds to the A1-A20 ?? That is? What is the original serial number? 1-20 -- corresponds to a A1-A20?
???? # Define? Char_num? 20 ???????????? // From 1? Start number ?????? Int ?? Nindex = 300 ;???????????? // Nindex? The corresponding value ?????? Int ?? Ncorrespondingindex = nIndex-1 ;?????????????????? ///////////////////////////////? The ing rules are the same ?? //////////////////////////////////////// ///???????????? //? Sure? I ?? In? 0-----char_num * 26-1? Between ?????? Int? I = ncorrespondingindex % (char_num * 26 );?????? // The letter or digit corresponding to the number? ? Before the letter corresponding to this number, there are ncharposition letters ,? The letter at this position is :? 0x41 + ncharposition ?????? Int ?? Ncharposition =? I/char_num ;?????? Char? P = 0x41 + ncharposition ;???????????? // Digit corresponding to the number ?? The value range is [1, char_num ]?????? Int? Nnum = I % char_num + 1 ;???
Summary:
???????????? When a number starts from 1 and is mapped to it, it is difficult to find the rule ???????????? In this case, what should I do ????????????? Next, let's look at the rule first ,? Instead, the number is processed first ,? Maps its equivalence to another sequence .???????????? If the rule of this sequence is easy to find, then we can directly use the rule of this sequence .??????????????????????? What kind of thinking is this indirect solution strategy ????????????? I think it should be to process the previous conversion ideas and pre-process the data ,? What will be difficult to solve? Is the equivalent value converted to a problem that is relatively easy to handle?
Used in this article? Calligraphy and painting novel software? Released, the content has nothing to do with the software, and the painting and calligraphy novel software? More comfortable reading, more comfortable writing, and easier Publishing.
Map numbers to letters ?. XML