最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
身份证15To18 的算法
时间:2022-07-02 12:07:59 编辑:袖梨 来源:一聚教程网
using System;
using System.Threading;
namespace KeyboardRecord
{
///
/// Class1 的摘要说明。
///
class Class1
{
///
/// 应用程序的主入口点。
///
[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];
}
}
}
using System.Threading;
namespace KeyboardRecord
{
///
/// Class1 的摘要说明。
///
class Class1
{
///
/// 应用程序的主入口点。
///
[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];
}
}
}
相关文章
- 地下城堡4骑士与破碎编年史初光神官有哪些流派 09-17
- 嘟嘟脸恶作剧克萝伊技能怎么样 09-17
- 新三国志曹操传驯马场有什么玩法 09-17
- 全境封锁曙光武器怎么获取 09-17
- 鹅鸭杀丧葬者如何玩 09-17
- 剑与远征启程沙利叶强技能怎么样 09-17