参考代码:
#include<bits/stdc++.h> using namespace std; int x[17] = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5 ,8, 4, 2 }; char last[11] = { '1', '0', 'x','9','8' ,'7' ,'6', '5', '4', '3', '2' }; int main() { int sum = 0; char original[16]; char now[19]; cin >> original; for (int i = 0; i < 17; i++) { if (i < 6)now[i] = original[i]; else if (i == 6) now[i] = '1'; else if (i == 7) now[i] = '9'; else now[i] = original[i - 2]; } for (int i = 0; i < 17; i++) { sum += (now[i] - '0') * x[i]; } sum = sum % 11; now[17] = last[sum]; now[18] = '\0'; cout << now; }
0.0分
1 人评分