求助60分

P1055 [NOIP2008 普及组] ISBN 号码

```cpp #include<bits/stdc++.h> using namespace std; string s; int ctoi(char a){ int b = a - '0'; // b = 1; 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(); if(s[12] == ID || (s[12] == 'X' && ID == 10)){ cout << "Right" << endl; }else{ for(int i=1; i<=12; i++){ if(i == 12){ cout << ansISBN.str() << "-" << ID << endl; return 0; } ansISBN << s[i-1]; } } } ``` 改成这个b样子
by Redl1ght_S @ 2023-10-10 21:44:57


|