#include<iostream>
#include<stdlib.h>
#include<string>
#include<iterator>
#include<vector>
#define NUM 14
using namespace std;
int main() {
string Str,targ;
string::iterator istrA;
cin >> Str;//3
int sum=0,count=1;
vector<int> num;
/*
输入字符串的方式
1,getline(cin, Str);
2, char str[NUM];
cin >> str;
Str = string{ str };
3, cin>>Str;
*/
for (istrA = begin(Str); istrA != end(Str)-1; ++istrA) {
if (*istrA != '-') {
num.push_back(*istrA - '0');
}
}
for (vector<int>::iterator itA = begin(num); itA!=end(num); ++itA,++count) {
sum += (*itA)*count;
}
if (sum % 11 == Str.at(Str.size() - 1)-'0') {
cout << "Right";
}
else if(10 == sum % 11 && Str.at(Str.size() - 1) == 'X'){
cout << "Right";
}
else {
if (10 == sum % 11) {
Str.at(Str.size() - 1) = 'X';
}
else {
Str.at(Str.size() - 1) = sum % 11+'0';
}
cout << Str;
}
return 0;
}
/*
过程中遇到的问题
忘记处理'X'问题
*/
CCF计算机软件能力认证试题:201312-2 isbn号码校验
最新推荐文章于 2024-07-18 17:40:16 发布