• 一个身份证号码转换程序


    /*
    * 身份证号码结构:
    *         十七位数字本体 + 一位校验码 
    *   从左到右依次为: 
    *       六位数地址码+八位数出身日期+三位数顺序码和一位校验码 

    *    地址码       : 由出生地区行政码划分
    *    年出生日期码 : 年月日,之间不用分隔符
    *    顺序码       : 同年同月同日生,男为奇数,女为偶数
    *    校验码       : (1)十七位数字本体码加权求和公式
    *                          s = sum(ai*wi),i=0,...,16
    *                           ai: 第i位置上的身份证号码数字值
    *                            wi: 第i位置上的加权因子
    *                             wi: 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2   
    *                    (2)求模
    *                           Y = mod(s,11) 
    *                    (3)通过模得到对应的校验码
    *                           Y: 0 1 2 3 4 5 6 7 8 9 10 
    *                           校验码: 1 0 X 9 8 7 6 5 4 3 2
    */


    ///////////////////////////////////////////////////////////
    #include <iostream>
    #include 
    <fstream>
    #include 
    <cstdlib>
    #include 
    <assert.h>

    #pragma warning(disable:4786)

    using namespace std;

    ///////////////////////////////////////////////////////////
    // 参数入口定义 
    #define  IN  
    #define  OUT 
    // 常用值定义
    #define  FALSE 0
    #define  TRUE  !(FALSE)   
    const int MODIFY_SPLITER = 1;
    const int MODIFY_LENGTH  = 2;
    // 对应表格定义
    // 加权因子 
    const unsigned int  w[17= 
          
    7910584216379105842
          }

    // 校验码 
    const char check_code[11= {
          
    '1''0''X''9''8''7''6''5''4''3''2'
          }
    ;
    ///////////////////////////////////////////////////////////
    // 函数声明

    ///////////////////////////////////////////////////////////////////////////
    // 这个函数从OOP角度讲应该是private属性的
    //----------------------------------------------------------------------//
    void ChangeIDInLine(IN const char *source, OUT char *dest, IN unsigned int from);
    /*
     【source】:   以'
    /*
    *
    * Copyright (c) 2011 Ubunoon.
    * All rights reserved.
    *
    * email: netubu#gmail.com replace '#' to '@'
    * http://www.cnblogs.com/ubunoon
    * 欢迎来邮件定制各类验证码识别,条码识别,图像处理等软件
    * 推荐不错的珍珠饰品,欢迎订购 * 宜臣珍珠(淡水好珍珠) */
  • 相关阅读:
    POJ1087 A Plug for UNIX 网络流
    HDU4405 Aeroplane chess 期望DP
    POJ1062 昂贵的聘礼 区间枚举
    HDU4403 A very hard Aoshu problem 枚举
    HDU4407 Sum 容斥定理
    POJ2750 Potted Flower 线段树+DP
    软件项目开发流程以及人员职责
    10款最流行的开源Web设计工具
    C# 把\\r\\n替换为\r\n
    jquery validation 用到的输入验证正则表达式
  • 原文地址:https://www.cnblogs.com/ubunoon/p/2058928.html
Copyright © 2020-2023  润新知