国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

用C#實(shí)現(xiàn)由15位身份證號(hào)升級(jí)到18位的算法

2019-11-18 16:53:11
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
1using System;
 2using System.Collections;
 3
 4public class MyClass
 5{
 6    public static void Main()
 7    {
 8        Console.WriteLine(per15To18("429005811009091"));
 9        RL();
10    }
11   
12    public static string per15To18(string perIDSrc)
13  {
14   int iS = 0;
15
16   //加權(quán)因子常數(shù)
17   int[] iW=new int[]{7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
18   //校驗(yàn)碼常數(shù)
19   string LastCode="10X98765432";
20   //新身份證號(hào)
21   string perIDNew;
22
23   perIDNew=perIDSrc.Substring(0,6);
24   //填在第6位及第7位上填上‘1’,‘9’兩個(gè)數(shù)字
25   perIDNew += "19";
26
27   perIDNew += perIDSrc.Substring(6,9);
28
29   //進(jìn)行加權(quán)求和
30   for( int i=0; i<17; i++)
31   {
32    iS += int.Parse(perIDNew.Substring(i,1)) * iW[i];
33   }
34    
35   //取模運(yùn)算,得到模值
36   int iY = iS%11;
37   //從LastCode中取得以模為索引號(hào)的值,加到身份證的最后一位,即為新身份證號(hào)。
38   perIDNew += LastCode.Substring(iY,1);
39
40   return perIDNew;
41  }
42
43
44
45   
46    Helper methods#region Helper methods
47
48    PRivate static void WL(object text, params object[] args)
49    {
50        Console.WriteLine(text.ToString(), args);   
51    }
52   
53    private static void RL()
54    {
55        Console.ReadLine();   
56    }
57   
58    private static void Break()
59    {
60        System.Diagnostics.Debugger.Break();
61    }
62
63    #endregion
64}
http://m.survivalescaperooms.com/goody9807/archive/2006/11/13/559378.html
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 理塘县| 渭南市| 濉溪县| 郯城县| 蓬安县| 黑河市| 万全县| 扎囊县| 苍南县| 泌阳县| 延长县| 邛崃市| 清镇市| 边坝县| 吕梁市| 乃东县| 平阴县| 武宁县| 平罗县| 安化县| 景东| 洪湖市| 泰州市| 茶陵县| 海城市| 太保市| 闽清县| 揭西县| 武功县| 融水| 肇州县| 微山县| 克山县| 光泽县| 曲阜市| 鹤壁市| 芒康县| 福贡县| 玉屏| 化德县| 宜章县|