文章
12
粉丝
693
获赞
3
访问
126.8k
#include <stdio.h>
#include <string.h>
#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};
char match[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
char str[20];
while(scanf("%s", str) != EOF) {
int len = strlen(str);
if(len > 18) printf("Wrong ID\n");
else {
if(str[len - 1] == 'x') str[len - 1] -= 32;
long long sum = 0;
for(int i = 0; i < len - 1; ++i) {
sum += weight[i] * (str[i] - '0');
}
if(match[sum % 11] == str[len - 1]) printf("Correct ID\n");
else printf("Wrong ID\n");
}
}
return 0;
}
登录后发布评论
而且X应该是大写的,否则样例过不了