0分,大佬们帮我看看怎么改

P1055 [NOIP2008 普及组] ISBN 号码

wangchunyuIO @ 2025-01-01 19:35:50

#include<bits/stdc++.h>
using namespace std;
char a[13];
 int l=0;
 int main(){
    cin>>a;
    int k=0;
    for(int i=0;i<11;i++){
    if(a[i]!='-'){
        k++;
        l+=k*(a[i]-'0');
    }
    l%=11;
    char c;
    if(l==10){
         c='X';
    }else{
        c=l+'0';
    }
    if(a[12]==c){
        cout<<'Right'<<endl;
    }else{
        cout<<c<<endl;
    }
    return 0;
}
}

by WE_TRT @ 2025-01-01 19:38:24

#include<bits/stdc++.h>
using namespace std;
string b;
int main(){
    int a[10001]={0},i,j,sum=0,k=0,len;
    bool f=false;
    cin>>b;
    len=b.size();
    for(i=0;i<len-2;i++){
        if(b[i]>='0'&&a[i]<='9'){
            a[k]=b[i]-'0';
            sum=sum+a[k]*(k+1);
            k++;
            sum%=11;
        }
    }
    if(sum==10){
        if(b[len-1]!='X'){
            for(i=0;i<len-1;i++){
                cout<<b[i];
            }
            cout<<"X";
        }
        else{
            cout<<"Right";
        }
    }
    else{
        if(b[12]-'0'==sum){
            cout<<"Right";
        }
        else{
            for(i=0;i<len-1;i++){
                cout<<b[i];
            }
            cout<<sum;
        }
    }
    return 0;
}

by WA_csp_noip @ 2025-01-01 19:57:48

@wangchunyuIO

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

const int p = 11;

int n;
char s[20];

int soanws() {
    int ans = 0, x = 0;
    for (int i = 1; i <= n; i++)
        if (s[i] != '-')
            ans += (++x) * (s[i] - 48);
    return ans % p;
}

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1) - 1;
    int ans = soanws();
    char k;
    if (ans == 10)
        k = 'X';
    else
        k = ans + 48;
    if (s[n + 1] == k)
        printf("Right");
    else {
        for (int i = 1; i <= n; i++)
            printf("%c", s[i]);
        printf("%c", k);
    }
    return 0;
}

by b__b @ 2025-01-01 20:07:15

#include <cstdio>
char s[15];
int main() {
    scanf("%s", s);
    int sum = 0, k = 0;
    for (int i = 0; i < 12; ++i) if (s[i] >= '0' && s[i] <= '9') sum += (s[i] - '0') * ++k;
    if ((sum %= 11) == (s[12] == 'X' ? 10 : s[12] - '0')) puts("Right");
    else s[12] = '\0', fputs(s, stdout), putchar(sum == 10 ? 'X' : sum + '0');
    return 0;
}

|