【NOIP2008】【Luogu1055】ISBN号码

problem

solution

codes

#include<iostream>
#include<string>
using namespace std;
int ans;
int main(){
    string str;  cin>>str;
    for(int i = 0, j = 1; i < 12; i++){
        if(str[i] != '-')ans += (str[i]-'0')*j++;
    }
    ans %= 11; ans+='0'; if(ans == '9'+1)ans = 'X';
    if(ans == str[12])cout<<"Right\n";
    else { str[12] = ans; cout<<str<<"\n"; }
    return 0;
}
posted @ 2018-06-06 21:41  gwj1139177410  阅读(135)  评论(0编辑  收藏  举报
选择