pat_b_1031 查验身份证
来源:互联网 发布:淘宝退货地址 编辑:程序博客网 时间:2024/05/02 00:25
http://www.patest.cn/contests/pat-b-practise/1031
分析: 简单题
代码:
<span style="font-size:18px;">//pat b 1031#include <iostream>#include <stdio.h>#include <string>#include <cstring>#include <ctype.h>using namespace std;const int maxn = 101;const char M[] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};const int W[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};int n;string s;bool judge(){ for(int i=0; i< 17; i++){ if(!isdigit(s[i])) return false; } int sum=0; for(int i=0; i<17; i++){ sum += (s[i]-'0')*W[i]; } char c =M[ sum % 11 ]; return c==s[17] ? true : false;}int main(){ freopen("in.txt","r",stdin); bool flag; while(cin>>n){ flag=false; for(int i=0; i<n; i++){ cin>>s; if(!judge()){ cout<<s<<endl; flag=true; } } if(!flag) cout<<"All passed"<<endl; } return 0;}</span>
0 0
- pat_b_1031 查验身份证
- 查验身份证
- 查验身份证
- 查验身份证
- 查验身份证
- 查验身份证
- 查验身份证
- 查验身份证
- 1031. 查验身份证(15)
- 1031. 查验身份证
- 1031. 查验身份证(15)
- 1031. 查验身份证(15)
- 查验身份证(15)
- 1031. 查验身份证(15)
- 1031. 查验身份证(15)
- 1031. 查验身份证(15)
- 1031. 查验身份证(15)
- 1031. 查验身份证(15)
- mac 使用adb
- PHP在嵌入式linux上的移植
- 使用Word模板制作Moodle XML格式的测验题,并且导入
- linux-分析CPU的瓶颈
- 关于尔雅平台通识课《创业创新执行力》的考试方法与考试须知
- pat_b_1031 查验身份证
- 使用IntelliJ IDEA开发前的基本设置,有助于提高开发效率
- Android界面上弹出一些对话框
- 根据数字打印对应的图案
- 数组学生管理
- uva 10673
- 中奖问题
- 中奖问题
- ServletResponse注意事项