感觉没错啊!DALAO们帮帮我吧!必关!

P1055 [NOIP2008 普及组] ISBN 号码

zyx13765814016 @ 2024-10-10 16:22:13

#include<bits/stdc++.h>
using namespace std;
char s[13],a;
int main(){
    int n;
    cin>>s[1]>>s[2]>>s[3]>>s[4]>>s[5]>>s[6]>>s[7]>>s[8]>>s[9]>>s[10]>>s[11]>>s[12]>>s[13];
    n=(s[1]*1+s[3]*2+s[4]*3+s[5]*4+s[7]*5+s[8]*6+s[9]*7+s[10]*8+s[11]*9)%11;
    if(n==10){
        a='X';
    }
    else{
        a=n;
    }
    if(a==s[13]){
        cout<<"Right";
    }
    else{
        cout<<s[1]<<s[2]<<s[3]<<s[4]<<s[5]<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<s[11]<<a;
    }
    return 0;
}

by lovely_codecat @ 2024-10-10 16:29:34

@zyx13765814016

#include<bits/stdc++.h>
using namespace std;
char s[130],a;
int main(){
    int n;
    cin>>(s+1);

    n=(s[1]*1+s[3]*2+s[4]*3+s[5]*4+s[7]*5+s[8]*6+s[9]*7+s[10]*8+s[11]*9-(45*'0'))%11;
    if(n==10){
        a='X';
    }
    else{
        a=n+'0';
    }
    if(a==s[13]){
        cout<<"Right";
    }
    else{
        cout<<s[1]<<s[2]<<s[3]<<s[4]<<s[5]<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<s[11]<<'-'<<a;
    }
    return 0;
}

by lsrsrl @ 2024-10-10 16:41:34

@zyx13765814016

#include <bits/stdc++.h>

using namespace std;

char s[21];

int main() {
    scanf ("%s", s + 1);
    int n = 13, sum = 0, x = 0;
    for (int i = 1; i < n; i++)
        if (s[i] != '-') {
            int y = s[i] - '0';
            ++x;
            sum += x * y;
        }
    sum %= 11;
    char c;
    if (sum == 10)
        c = 'X';
    else
        c = sum + '0';
    if (s[n] == c)
        printf ("Right");
    else {
        for (int i = 1; i < n; i++)
            printf ("%c", s[i]);
        printf ("%c", c);
    }   
    return 0;
}

by zyx13765814016 @ 2024-10-10 17:04:58

谢谢


|