文章
1
粉丝
9
获赞
2
访问
945
C++
基于map,纯粹是想用时键值对(实际上直接数组映射就行)
别的没啥,注意两个bug就行
#include<bits/stdc++.h>
using namespace std;
int main()
{
map<int,char>dict;
dict[0] = '1';
dict[1] = '0';
dict[2] = 'X';
dict[3] = '9';
dict[4] = '8';
dict[5] = '7';
dict[6] = '6';
dict[7] = '5';
dict[8] = '4';
dict[9] = '3';
dict[10] = '2';
int weight[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
string s;
while(cin>>s){
if(s.length()!=18)cout<<"ID Wrong"<<endl;
else{
int temp = 0;
for(int i = 0; i < 17; i++){
temp+=(s[i]-'1'+1)*weight[i];
}
temp = temp%11;
if(s[17]==dict[temp])cout<<"ID Corrent"<<endl;
else cout<<"ID Wrong"<<endl;
}
}
}
登录后发布评论
暂无评论,来抢沙发