文章
43
粉丝
180
获赞
21
访问
196.1k
#include <iostream>
using namespace std;
string id;
int val[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char mp[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
bool check(string s)
{
if (s.size() != 18) return false;
int c = 0;
for (int i = 0; i < s.size() - 1; i ++ )
c += val[i] * (s[i] - '0');
if (mp[c % 11] == s[17]) return true;
else return false;
}
int main()
{
while (cin >> id)
if (check(id)) puts("ID Corrent");
else puts("ID Wrong");
return 0;
}
登录后发布评论
暂无评论,来抢沙发