vijos p1484 ISBN号码
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main() {
     
 string str;
 cin >> str;
 int key = 0;
 int m = 0;
 for (int i = 0; i < 11; i++)
 {
     
 if (isdigit(str[i]))
 {
     
 m++;
 key += (str[i] - '0') * (m);
 }
 }
 if (key % 11 == 10)
 {
     
 if (str[12] == 'X')
 cout << "Right" << endl;
 else {
     
 str[12] = 'X';
 cout << str << endl;
 }
 }
 else
 {
     
 if (str[12] - '0' == key % 11)
 cout << "Right" << endl;
 else
 {
     
 str[12] = key % 11 + '0';
 cout << str << endl;
 }
 }
 return 0;
}
   posted @ 
   2017-10-13 23:16 Ruoh3kou 阅读( 
   ...) 评论( 
   ...) 编辑 收藏