当前位置:网站首页>B1031 check ID card
B1031 check ID card
2022-07-27 05:20:00 【Ye Chen】
1031 Check your ID card (15 branch )
A legal ID number is from 17 Location 、 Date number and sequence number plus 1 Bit check code composition . Check code calculation rules are as follows :
First of all, to the front 17 Bit number weighted sum , The weight is assigned to :{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; Then the sum of the calculated values is compared to the 11 Take the modulus to get the value Z; Finally, according to the following relationship Z Value and check code M Value :
Z:0 1 2 3 4 5 6 7 8 9 10
M:1 0 X 9 8 7 6 5 4 3 2
Now give me some ID number. , Please verify the validity of the check code , And output the problem number .
Input format :
Enter the first line to give a positive integer N(≤100) The number of the ID number entered. . And then N That's ok , Each line gives 1 individual 18 I. D. number .
Output format :
Output each line in the order of input 1 Question Id number . This is not before the test 17 Is it reasonable , Just before checking 17 Are all digits and last 1 Accurate calculation of bit check code . If all the numbers are OK , The output All passed.
sample input
4
320124198808240056
12010X198901011234
110108196711301866
37070419881216001X
sample output
12010X198901011234
110108196711301866
37070419881216001X
sample input
2
320124198808240056
110108196711301862
sample output
All passed
Topic analysis :
- Be careful Before inspection 17 Whether all bits are numbers
- Calculation 1 Check whether the bit check code is correct .
The code is as follows :
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
char m[]={'1','0','X','9','8','7','6','5','4','3','2'};
int z[]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
cin>>n;
char s[101][19];
int sum[101]={0},flag[101]={0},g=0;
for(int i=0;i<n;i++){
scanf("%s",s[i]);
s[i][18]='\0';
for(int j=0;j<17;j++){
if(s[i][j]<='9'&&s[i][j]>='0'){
sum[i]+=(s[i][j]-'0')*z[j];
}else{
flag[i]=1;
break;
}
}
if(flag[i]==0){
int a=sum[i]%11;
if(m[a]-s[i][17]!=0){
flag[i]=1;
}
}
if(flag[i]==1){
g++;
}
}
if(g==0){
cout<<"All passed";
}else{
for(int i=0;i<n;i++){
if(flag[i]==1){
printf("%s\n",s[i]);
}
}
}
return 0;
}
边栏推荐
- LocalDateTime和ZonedDateTime
- 笔记系列k8s编排MySQL容器-有状态的容器创建过程
- Another skill is to earn 30000 yuan a month+
- 34. 分析flexible.js
- [optical flow] - data format analysis, flowwarp visualization
- ERROR! MySQL is not running, but PID file exists
- Dialog data transfer
- 内部类与静态内部类区别及举例
- Acceptance and neglect of events
- JVM上篇:内存与垃圾回收篇六--运行时数据区-本地方法&本地方法栈
猜你喜欢

JVM上篇:内存与垃圾回收篇六--运行时数据区-本地方法&本地方法栈

Installation and template setting of integrated development environment pychar

Bean的生命周期&&依赖注入*依赖自动装配

ssm框架整合

精选用户故事|洞态在聚水潭的误报率几乎为0,如何做到?

JVM上篇:内存与垃圾回收篇十二--StringTable

JVM Part 1: memory and garbage collection part 12 -- stringtable

34. Analyze flexible.js

Dialog introduction

弹球小游戏
随机推荐
The provision of operation and maintenance manager is significantly affected, and, for example, it is like an eep command
JVM Part 1: memory and garbage collection part 3 - runtime data area - overview and threads
数据库连接池&&Druid使用
JVM上篇:内存与垃圾回收篇--运行时数据区四-程序计数器
JVM上篇:内存与垃圾回收篇三--运行时数据区-概述及线程
JVM上篇:内存与垃圾回收篇五--运行时数据区-虚拟机栈
The difference between strlen and sizeof
JVM上篇:内存与垃圾回收篇六--运行时数据区-本地方法&本地方法栈
Svn usage details
JVM上篇:内存与垃圾回收篇二--类加载子系统
笔记系列之docker安装Postgresql 14
传智教育|软件测试工程师未来的发展方向有哪些?
枚举类实现单例模式
JVM Part 1: memory and garbage collection part 9 - runtime data area - object instantiation, memory layout and access location
JVM上篇:内存与垃圾回收篇十一--执行引擎
Integrate SSM
Install pyGame
Test basis 5
Dialog introduction
Introduction to Kali system ARP (network disconnection sniffing password packet capturing)