亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

麻煩各位大佬幫我看看這里哪里出錯了,運行完會報錯

using System;

using System.Text.RegularExpressions;


namespace _1901203021_廖海鵬

{

? ? class Program

? ? {

? ? ? ? static void Main(string[] args)

? ? ? ? {

? ? ? ? ? ? Console.Write("身份證號碼:");

? ? ? ? ? ? string id = Convert.ToString(Console.ReadLine());

? ? ? ? ? ? string expression = @"^d{18}$";

? ? ? ? ? ? if (Regex.IsMatch(id, expression) == false)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? Console.Write(false);

? ? ? ? ? ? }

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

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

? ? ? ? ? ? //while (System.Text.Encoding.Default.GetByteCount(id) != 18)

? ? ? ? ? ? //{

? ? ? ? ? ? //? ? Console.WriteLine("身份證輸入錯誤,請重新輸入");

? ? ? ? ? ? //? ? id = Convert.ToString(Console.ReadLine());

? ? ? ? ? ? //}

? ? ? ? ? ? //char[] ID = id.ToCharArray();

? ? ? ? ? ? int[] ID = new int[id.Length];

? ? ? ? ? ? for (int i = 0; i < id.Length; i++)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? int ii = Convert.ToInt32(id[i]);

? ? ? ? ? ? ? ? ID[i] = ii;

? ? ? ? ? ? }

? ? ? ? ? ? int S = 0;

? ? ? ? ? ? for (int x = 0; x < 17; x++)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? int Ai = ID[x];//將ID聲明為int

? ? ? ? ? ? ? ? int Wi = wi[x];

? ? ? ? ? ? ? ? S += Ai * Wi;

? ? ? ? ? ? }

? ? ? ? ? ? int Y = S % 11;

? ? ? ? ? ? Y = Convert.ToInt32(checkNum[Y]);

? ? ? ? ? ? if (ID[18] == Y)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? Console.WriteLine("校驗成功,此身份證號為真");

? ? ? ? ? ? }

? ? ? ? ? ? else

? ? ? ? ? ? {

? ? ? ? ? ? ? ? Console.WriteLine("校驗失敗,此身份證號為假");

? ? ? ? ? ? }




? ? ? ? }

? ? ? ? }

? ? }


正在回答

3 回答

你這寫的是什么鬼?????

0 回復 有任何疑惑可以回復我~

剛剛發錯了,是這個,為什么會跳出錯誤?

0 回復 有任何疑惑可以回復我~

? ? ? ? static void Main(string[] args)

? ? ? ? {

? ? ? ? ? ? Console.Write("身份證號碼:");

? ? ? ? ? ? string id = Convert.ToString(Console.ReadLine());

? ? ? ? ? ? string expression = @"^d{18}$";

? ? ? ? ? ? if (Regex.IsMatch(id, expression) == false)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? Console.Write(false);

? ? ? ? ? ? }

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

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

? ? ? ? ? ? //while (System.Text.Encoding.Default.GetByteCount(id) != 18)

? ? ? ? ? ? //{

? ? ? ? ? ? //? ? Console.WriteLine("身份證輸入錯誤,請重新輸入");

? ? ? ? ? ? //? ? id = Convert.ToString(Console.ReadLine());

? ? ? ? ? ? //}

? ? ? ? ? ? char[] _id = id.ToCharArray();

? ? ? ? ? ? int[] ID = new int[_id.Length];

? ? ? ? ? ? for (int i = 0; i < _id.Length; i++)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? int ii = Convert.ToInt32(_id[i]);

? ? ? ? ? ? ? ? ID[i] = ii;

? ? ? ? ? ? }

? ? ? ? ? ? int S = 0;

? ? ? ? ? ? for (int x = 0; x < 17; x++)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? int Ai = ID[x];

? ? ? ? ? ? ? ? int Wi = wi[x];

? ? ? ? ? ? ? ? S += Ai * Wi;

? ? ? ? ? ? }

? ? ? ? ? ? int Y = S % 11;

? ? ? ? ? ? char z = Convert.ToChar(Y);

? ? ? ? ? ? z = checkNum[Y];

? ? ? ? ? ? if (ID[18] == z)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? Console.WriteLine("校驗成功,此身份證號為真");

? ? ? ? ? ? }

? ? ? ? ? ? else

? ? ? ? ? ? {

? ? ? ? ? ? ? ? Console.WriteLine("校驗失敗,此身份證號為假");

? ? ? ? ? ? }

? ? ? ? }


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

麻煩各位大佬幫我看看這里哪里出錯了,運行完會報錯

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號