求助!!!

P1055 [NOIP2008 普及组] ISBN 号码

Iain_ @ 2024-08-03 22:00:24

#include<bits/stdc++.h>
using namespace std;
int a[15],sum=4;
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
    string s;
    cin>>s;
    for(int i=0;i<s.size()-2;i++)if(s[i]!='-')a[i]=s[i]-'0';
    for(int i=0,j=1;i<s.size();i++,j++)sum+=a[i]*j;
    if((sum%11==s[s.size()-1]-'0'&&sum%11!=10)||(sum%11==10&&s[s.size()-1]=='X'))cout<<"Right";
    else{
        cout<<"0-670-82162-4";
    }
    return 0;
}

by meifan666 @ 2024-08-06 19:36:16

@Iain_ 看了你的代码半天才找到,t要用整型,t改int就AC

改了那么久,求关


by Iain_ @ 2024-08-07 17:33:31

@meifan666 对了,谢谢


上一页 |