Source: http://www.study-code.com/visual-studio/c/72916.htm
I have not been dealing with statistical reports for many years. I do not know whether the Corporate code exists yet. Every organization 10 years ago, whether it is an organization, an enterprise, or a social group, requires this code.
As a nostalgia, I posted this C language function code more than a decade ago, and now I am writing a demo program temporarily:
# Include <stdio. h>
# Include <string. h>
# Include <stdlib. h>
/* Obtain the Organization's legal entity code checkpoint */
Char GetLegalPersonCheckCode (char * code)
{
Const int Value [] = {3, 7, 9, 10, 5, 8, 4, 2 };
Int x, check = 0;
For (x = 0; x <8; x ++)
{
If (code [x]> = '0' & code [x] <= '9 ')
Check + = (code [x]-'0') * Value [x];
Else if (code [x]> = 'A' & code [x] <= 'Z ')
Check + = (10 + code [x]-'A') * Value [x];
Else if (code [x]> = 'A' & code [x] <= 'Z ')
Check + = (10 + code [x]-'A') * Value [x];
}
Check = 11-(check % 11 );
Switch (check)
{
Case 10:
Check = 'X ';
Break;
Case 11:
Check = '0 ';
Break;
Default:
Check + = '0 ';
}
Return check;
}
Int main (int argc, char * argv [])
{
Char lpCode [10];
Printf ("Enter the Organization's legal code to be verified :");
Scanf ("% s", lpCode );
If (strlen (lpCode )! = 9)
Printf ("the number of digits entered in the Organization's legal representative code is incorrect! ");
Else if (GetLegalPersonCheckCode (lpCode )! = LpCode [8])
Printf ("the entered unit legal entity code check bit is incorrect! ");
Else
Printf ("the Organization legal entity code % s is correct", lpCode );
System ("pause ");
Return 0;
}
I used to conduct statistics. I used to be the computer management director of the organization. I used to deal with the most statistics reports. This code is printed on each statistical professional monthly report, annual report, and various statistical census reports, code printing format: XXXXXXXX-X, "-" on the left is the 8 digit code, the right is a 1 digit Verification Code (0 -- 9 or X), each code bit is printed with a small box, only nine digits of code are input, and "-" is not input.
The example is very simple. You need to enter a unit legal entity code, check whether the entered code length is 9, call the GetLegalPersonCheckCode function to obtain the verification bit of the code, and compare it with the entered code verification code.
Some people may have noticed that I mentioned the eight-digit code on the left, but function compute contains letters such as a-z and A-Z, this is because many organizations did not have time to obtain the unit code from the technical supervision department, and the unit code must be filled in for various statistical reports. Therefore, the Statistics Department generally starts with two letters, it is followed by 6 digits to form a temporary unit code.
In fact, this function uses eight-digit unit code calculation and returns its verification code, which can not only verify the unit legal entity code, but also calculate the unit legal entity code, however, the formal unit code can only be reviewed and issued by the Technical Supervision Department to ensure that all unit codes nationwide are unique. As a Statistical Department, we only use it to calculate the temporary unit code.