只有一个AC点,求大佬看看

P1055 [NOIP2008 普及组] ISBN 号码

Shrimp123 @ 2024-02-06 17:46:17

#include<bits/stdc++.h>
using namespace std;

int main()
{
    string a;
    cin>>a;
    int sum;
    int num=1;
    for(int i=0; i<12; i++) {
        if(a[i]=='-')continue;
        sum+=(a[i]-'0')*num++;
    }
    if(((sum%11==10)&&(a[12]=='X'))||(a[12]-'0'==sum%11))cout<<"Right";
    else {
        for(int i=0; i<12; i++)cout<<a[i];
        if(sum%11==10)cout<<"X";
        else cout<<sum%11;
    }
    return 0;
}

by hema5177 @ 2024-02-06 18:50:21

@Shrimp123 把sum赋值为0试试?


by Shrimp123 @ 2024-02-07 10:06:09

@hema5177 全过了,谢谢佬!


by hema5177 @ 2024-02-07 11:53:06

@Shrimp123 不用谢qwq


|