An ID card number Conversion Program

Source: Internet
Author: User
Tags table definition
/**/ /*
* ID card number structure:
* 17-bit digital ontology + one-digit Verification Code
* From left to right:
* Six-digit address code + eight-digit origin date + three-digit sequential code and one-digit Verification Code

* Address code: divided by the Administrative Code of the birth area
* Date of Birth: year, month, and day without Separators
* Sequence code: Same year, same month, same day, odd male, and even female
* Verification Code: (1) 17-digit ontology code weighted sum formula
* S = sum (ai * WI), I = 0,..., 16
* Ai: ID card number at position I
* WI: Weighting Factor at position I
* WI: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
* (2) modulo
* Y = Mod (S, 11)
* (3) obtain the corresponding verification code through the modulo
* Y: 0 1 2 3 4 5 6 7 8 9 10
* Verification Code: 1 0x9 8 7 6 5 4 3 2
*/

/**/ //////////////////////////////////////// ///////////////////
# Include < Iostream >
# Include < Fstream >
# Include < Cstdlib >
# Include < Assert. h >

# Pragma Warning (Disable: 4786)

Using   Namespace STD;

/**/ //////////////////////////////////////// ///////////////////
// Parameter entry Definition
# Define In
# Define Out
// Definition of common values
# Define False 0
# Define True! (False)
Const   Int Modify_spliter =   1 ;
Const   Int Modify_length =   2 ;
// Corresponding table definition
// Weighting Factor
Const Unsigned Int W [ 17 ] =   ... {
7 , 9 , 10 , 5 , 8 , 4 , 2 , 1 , 6 , 3 , 7 , 9 , 10 , 5 , 8 , 4 , 2
} ;
// Verification Code
Const   Char Check_code [ 11 ] =   ... {
' 1 ' , ' 0 ' , ' X ' , ' 9 ' , ' 8 ' , ' 7 ' , ' 6 ' , ' 5 ' , ' 4 ' , ' 3 ' , ' 2 '
} ;
/**/ //////////////////////////////////////// ///////////////////
// Function Declaration

/**/ //////////////////////////////////////// ///////////////////////////////////
// This function should be private from the OOP perspective.
// ---------------------------------------------------------------------- //
Void Changeidinline (in Const   Char   * Source, out Char   * DeST, in unsigned Int From );
/**/ /*
[Source]:'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.