欢迎光临
我们一直在努力

身份证15To18 的算法-.NET教程,评论及其它

建站超值云服务器,限时71元/月

using system;

using system.threading;

namespace keyboardrecord

{

/// <summary>

/// class1 的摘要说明。

/// </summary>

class class1

{

/// <summary>

/// 应用程序的主入口点。

/// </summary>

[stathread]

static void main(string[] args)

{

//

// todo: 在此处添加代码以启动应用程序

//

string a = console.readline();

if (a.length!=15)

{

console.writeline("please input correct idnumber");

}

else

{

console.writeline(getcheckcode(a));

}

}

static string getcheckcode(string sfzh)

{

char[] strjiaoyan = {1, 0, x, 9, 8, 7, 6, 5, 4, 3, 2};

int[] intquan = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1};

string strtemp;

int inttemp = 0;

strtemp = sfzh.substring(0,6) + "19" + sfzh.substring(6);

for (int i=0;i<=strtemp.length-1;i++)

{

inttemp += int.parse(strtemp.substring(i,1))*intquan[i];

}

inttemp = inttemp % 11;

return strtemp + strjiaoyan[inttemp];

}

}

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 身份证15To18 的算法-.NET教程,评论及其它
分享到: 更多 (0)