经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

身份证

📝 题解 🔵 仅限 C++
题目描述
&nbsp;如果让你设计个程序,用什么变量保存身份证号码呢?长整数可以吗?不可以!<br /> &nbsp; 因为有人的身份证最后一位是"X"<br /> &nbsp; 实际上,除了最后一位的X,不会出现其它字母!<br /> &nbsp; 身份证号码18位 = 17位 + 校验码<br /> &nbsp; 校验码的计算过程:<br /> &nbsp; 例如:身份证前17位 = ABCDEFGHIJKLMNOPQ<br /> &nbsp; A~Q 每位数字乘以权值求和(每位数字和它对应的“权”相乘后累加)<br /> &nbsp; 17位对应的权值分别是:<br /> &nbsp; 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2<br /> &nbsp; 求出的总和再对11求模<br /> &nbsp; 然后按下表映射:<br /> &nbsp; 余数&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 1&nbsp;&nbsp; 2&nbsp;&nbsp; 3&nbsp;&nbsp; 4&nbsp;&nbsp; 5&nbsp;&nbsp; 6&nbsp;&nbsp; 7&nbsp;&nbsp; 8&nbsp;&nbsp; 9&nbsp;&nbsp; 10 <br /> &nbsp; 校验码: 1&nbsp;&nbsp; 0&nbsp;&nbsp; X&nbsp;&nbsp; 9&nbsp;&nbsp; 8&nbsp;&nbsp; 7&nbsp;&nbsp; 6&nbsp;&nbsp; 5&nbsp;&nbsp; 4&nbsp;&nbsp; 3&nbsp;&nbsp; 2 <br /> 输入身份证前17位,打印出校验码。
输入格式
<p> &nbsp; </p>
输出格式
样例
样例输入 1
13072719840805463
样例输出 1
X
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用