博客
关于我
PTA团队程序设计天梯赛 | L1-016 查验身份证 (15分)
阅读量:113 次
发布时间:2019-02-26

本文共 1092 字,大约阅读时间需要 3 分钟。

??????????

?????????????????????????????????????????17???????????????????

#include 
#include
#include
using namespace std;int q[17] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};char m[12] = "10X98765432";int main() { int n, i, flag = 0; char IdCard[19]; cin >> n; while (n--) { cin >> IdCard; flag = 0; for (i = 0; i < 17; i++) { if (!isdigit(IdCard[i])) { flag = 1; break; } } if (flag) { cout << IdCard; continue; } int sum = 0; for (i = 0; i < 17; i++) { sum += q[i] * (IdCard[i] - '0'); } int Z = sum % 11; if (Z < 0) Z += 11; if (m[Z] != IdCard[17]) { cout << IdCard; } } if (!flag) { cout << "All passed"; }}

?????????????????n???????????????????????????????????17?????????????????????????????????17????????????11????Z???????????????????????????????????????????

??????????????????"All passed"????????????????

转载地址:http://brcz.baihongyu.com/

你可能感兴趣的文章
python try except finally_Python3基础 try-except-finally 的简单示例
查看>>
Python Turtle图形窗口不显示任何内容
查看>>
Python tweepy写入到sqlite3 db
查看>>
Python TypeError:格式字符串的参数不足
查看>>
Python UI自动化测试Page Objects企业级实战
查看>>
Python趣味编程:用代码创造无限可能
查看>>
Python UI自动化测试三方库扩展详解
查看>>
Python UI自动化测试与Web UI自动化测试框架详解
查看>>
python谷歌翻译,2021年9月10日亲测可用,一次可以翻译十万,强烈star
查看>>
Python UI自动化测试数据驱动实战
查看>>
Python UI自动化测试集成UnitTest
查看>>
Python UI自动化测试集成UnitTest
查看>>
python unicode-escape
查看>>
Python unittest mock:是否可以在测试时模拟方法默认参数的值?
查看>>
Python unittest单元测试框架 TestSuite测试套件
查看>>
PYTHON调离线语音合成并实时播放
查看>>
python unittest高级特性!
查看>>
Python unittest:如何将标准输出消息临时重定向到缓冲区并测试其内容?
查看>>
Python urllib/Requests下载文件失败,但浏览器下载失败
查看>>
Python urllib2 文件上传问题
查看>>