文章
20
粉丝
147
获赞
13
访问
51.7k
#include <bits/stdc++.h>
using namespace std;
int main()
{
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.size() != 18)
{
cout << "ID Wrong" << endl;
continue;
}
char y[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int sum = 0, x = 0;
for (int i = 0; i < s.size() - 1; i++)
{
sum += ((s[i] - '0') * weight[i]);
}
x = sum % 11;
if (y[x] != s[s.size() - 1])
{
cout << "ID Wrong" << endl;
}
else
{
cout << "ID Corrent" << endl;
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发