70分求助

P1055 [NOIP2008 普及组] ISBN 号码

ouruiheng0929 @ 2023-12-11 22:40:37

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll i,s=0,d,m,k=0;
char a[12],x,d1;
int main(){
    for(i=0;i<=11;i++){
        cin>>x;
        if(x!='-'){
            a[i]=x;
            k++;
            s+=(a[i]-48)*k; 
        } 
    }
    cin>>d1;
    if(d1=='X') d=10;
    else  d=d1-48;
    if(s%11==d) cout<<"Right";
    else cout<<a[0]<<"-"<<a[2]<<a[3]<<a[4]<<"-"<<a[6]<<a[7]<<a[8]<<a[9]<<a[10]<<"-"<<s%11;
    return 0;
}

by bookvalley @ 2023-12-21 23:57:08

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a1,a2,a3,a4,a5,a6,a7,a8,a9,a10;
    int x=0;
    scanf("%c-%c%c%c-%c%c%c%c%c-%c",&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10);
    x=(a1-'0')*1+(a2-'0')*2+(a3-'0')*3+(a4-'0')*4+(a5-'0')*5+(a6-'0')*6+(a7-'0')*7+(a8-'0')*8+(a9-'0')*9;
    x=x%11;
    if(x%11==10&&a10=='X'){
        printf("Right");
    }
    else if(x%11==a10-'0'){
        printf("Right");
    }
    else{
        printf("%c-%c%c%c-%c%c%c%c%c-%c",a1,a2,a3,a4,a5,a6,a7,a8,a9,x==10?'X':x+'0');
    }
    return 0;
}

by bookvalley @ 2023-12-21 23:57:45

@ouruiheng0929


by bookvalley @ 2023-12-21 23:58:28

同学的力量~~~


by ouruiheng0929 @ 2024-07-31 12:47:35

@bookvally @bookvalley xiexie


|