AcWing 3193. ISBN号码
原题链接
简单
作者:
Value
,
2021-03-06 15:06:23
,
所有人可见
,
阅读 327
#include <iostream>
#include <map>
using namespace std;
map<int, char> mp;
void init(){
for(int i = 0; i < 9; i ++ ) mp[i] = '0' + i;
mp[10] = 'X';
}
int main(){
init();
string s; cin >> s;
int sum = 0, k = 1;
for(int i = 0; i < s.size() - 1; i ++ ){
if(s[i] == '-') continue;
sum += (s[i] - '0') * (k ++ );
}
sum %= 11;
if(mp[sum] != s[s.size() - 1]){
s[s.size() - 1] = mp[sum];
cout << s << endl;
}else cout << "Right" << endl;
return 0;
}