求助60分
查看原帖
求助60分
1057897
Redl1ght_S楼主2023/10/10 21:36
  • #1,5,6,9寄了
#include<bits/stdc++.h>
using namespace std;
string s;

int ctoi(char a){
    int b = a - '0';
    return b;
}

int solve(void){
    int nowdigit = 1;
    long long modSum = 0;
    for(char c : s){
        if(c == '-'){
            continue;
        }else{
            modSum += nowdigit * ctoi(c);
            nowdigit++;
            if(nowdigit > 9){
                return modSum % 11;
            }
        }
    }
    return 0;
}

int main(){
    stringstream ansISBN;
    cin >> s;
    int ID = solve();
    for(int i=1; i<=13; i++){
        if(i == 13){
            if(s[i-1] == ID){
                cout << "Right" << endl;
            }else if(s[i-1] == 'X' && ID == 10){
                cout << "Right" << endl;
            }else{
                cout << ansISBN.str() << ID << endl;
            }
        }else{
            ansISBN << s[i-1];
        }
    }
    return 0;
}
2023/10/10 21:36
加载中...