Love丶FFC's Blog
一个合法的身份证号码由17位地区、日期编号和顺序编号加1位校验码组成。校验码的计算规则如下:
首先对前17位数字加权求和,权重分配为:{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};然后将计算的和对11取模得到值Z
;最后按照以下关系对应Z
值与校验码M
的值:
Z:0 1 2 3 4 5 6 7 8 9 10
M:1 0 X 9 8 7 6 5 4 3 2
现在给定一些身份证号码,请你验证校验码的有效性,并输出有问题的号码。
输入第一行给出正整数N(≤100)是输入的身份证号码的个数。随后N行,每行给出1个18位身份证号码。
按照输入的顺序每行输出1个有问题的身份证号码。这里并不检验前17位是否合理,只检查前17位是否全为数字且最后1位校验码计算准确。如果所有号码都正常,则输出All passed
。
4
320124198808240056
12010X198901011234
110108196711301866
37070419881216001X
12010X198901011234
110108196711301866
37070419881216001X
2
320124198808240056
110108196711301862
All passed
1.使用列表和字典来存放权重、校验码的对应关系
2.首先判断前17位是否都是数字,使用isnumeric方法,如果是,则求出权重和并判断与校验码是否匹配
3.设置一个标记,在整个循环过程中,只要有一个身份证号不正确, 就改变标记,为最后的输出提供判断
NOI = int(input()) Weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] # 每一位号码对应的权重 CheckCode = { # 利用字典来存放Z值与校验码的对应关系 0: '1', 1: '0', 2: 'X', 3: '9', 4: '8', 5: '7', 6: '6', 7: '5', 8: '4', 9: '3', 10: '2' } Judge = True # 所有身份证号是否都正确的标记,默认为是 for i in range(NOI): Identity = input() # 输入身份证号 Z = 0 if Identity[:17].isnumeric() == True: # 该身份证号的前17位全为数字 for j in range(17): # 求权重和 Z += int(Identity[j]) * Weights[j] Z %= 11 if CheckCode[Z] != Identity[17]: # Z值对应校验码与身份证号最后一位不匹配 print(Identity) Judge = False else: Judge = False print(Identity) if Judge == True: # 所有身份证号都正确 print("All passed")
Abupguele
cialis 20mg Federal Register, 56, 6426 6505
cheap louis vuitton bags
I just wanted to thank you for the fast service. and it could be they look great. I received them a day earlier than expected. like I will definitely continue to buy from this site. you decide I will recommend this site to my friends. Thanks!
cheap louis vuitton bags https://www.louisvuittonsoutletstore.com/
authentic louis vuitton outlet
I just wanted to thank you for the fast service. or they look great. I received them a day earlier than expected. prefer I will definitely continue to buy from this site. in any event I will recommend this site to my friends. Thanks!
authentic louis vuitton outlet https://www.cheapreallouisvuitton.com/
authentic cheap jordans
I just wanted to thank you for the fast service. to they look great. I received them a day earlier than expected. much I will definitely continue to buy from this site. in either case I will recommend this site to my friends. Thanks!
authentic cheap jordans https://www.realcheapretrojordanshoes.com/
cheap jordan shoes
I just wanted to thank you for the fast service. as well they look great. I received them a day earlier than expected. cherish the I will definitely continue to buy from this site. in any event I will recommend this site to my friends. Thanks!
cheap jordan shoes https://www.realjordansretro.com/
louis vuitton outlet
I just wanted to thank you for the fast service. to they look great. I received them a day earlier than expected. love the I will definitely continue to buy from this site. blue jays I will recommend this site to my friends. Thanks!
louis vuitton outlet https://www.bestlouisvuittonoutlet.com/
Knitant
Preclinical studies have harder erections levitra mieux que viagra
cheap jordans for sale
Read reviews and was a little hesitant since I had already inputted my order. and also but thank god, I had no issues. as good as the received item in a timely matter, they are in new condition. an invaluable so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans for sale https://www.realjordansshoes.com/
authentic louis vuitton outlet
Read reviews and was a little hesitant since I had already inputted my order. also but thank god, I had no issues. choose to received item in a timely matter, they are in new condition. no matter what so happy I made the purchase. Will be definitely be purchasing again.
authentic louis vuitton outlet https://www.louisvuittonsoutletonline.com/
invoimi
Ischemic optic neuropathy and inherited degenerative retinal disorders contraindicate sildenafil use; discontinuation of sildenafil is recommended if a sudden vision loss occurs fincar 5mg
invoimi
where to buy viagra connect Presence of a regularly gallop rhythm d
tZbGiTJJ
102 Combinations between tucatinib and monoclonal antibodies such as trastuzumab have been recently developed for the treatment of HER2 metastatic BC patients soft tab cialis
Rpejek
purchase tricor online cheap buy fenofibrate generic tricor price
XZsoTW
The AUC of ertugliflozin decreased by approximately 13, and Cmax decreased by approximately 21 compared to subjects with normal hepatic function how do i get viagra pills I ve been doing some research on The Colorado Experiment and came across this routine
Qixbmw
tadalafil sale viagra drug purchase sildenafil generic
Wzzuul
generic ketotifen 1 mg buy cheap ketotifen buy generic imipramine for sale
Oebxer
order mintop sale cost tamsulosin 0.4mg herbal ed pills
Xgexqz
precose medication order acarbose 25mg generic fulvicin without prescription