c++80求助

P1055 [NOIP2008 普及组] ISBN 号码

Brighteststar @ 2022-10-06 19:06:13

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
string a;
int main()
{
    getline(cin,a);
    int l=a.size()-1;
    int k=0;
    long long ans=0;
    for(int i=0;i<l;i++){
        if(a[i]>='0'&&a[i]<='9'){
            k++;
            ans+=int(a[i]-'0')*k;
        }
    }
    if(a[l]=='X'&&ans%11==10)cout<<"Right";
    else if(ans%11==int(a[l]-'0'))cout<<"Right";
    else{
        if(ans%11==10)a[l]='X';
        else a[l]=char(ans%11+'0');
        cout<<a;
    }
    return 0;
}

求大佬帮助(Orz)


by zzafanti @ 2022-10-12 22:27:42

我也碰到这个问题了 似乎把getline换成cin就ac了……

4#7#本地测试都没问题……交上去就错了,挺玄学的

awa


by zzafanti @ 2022-10-12 22:28:10

@zzafanti 4#8#


by liangkairui @ 2022-10-20 19:46:45

@zzafanti 还真的A了(Orz)


|