80分求助!!!

P1055 [NOIP2008 普及组] ISBN 号码

fly_neymar_jr @ 2024-02-25 10:58:15


#include <bits/stdc++.h>
using namespace std;
char a,b,c,d,e,f,g,h,i,j;
int ans;
int main(void)
{
    scanf("%c-%c%c%c-%c%c%c%c%c-%c",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
    ans=(a-'0')*1+(b-'0')*2+(c-'0')*3+(d-'0')*4+(e-'0')*5+(f-'0')*6+(g-'0')*7+(h-'0')*8+(i-'0')*9;
    ans%=11;
    if(j=='x' && ans==10 || ans==j-'0')
    printf("Right\n");
    else
    printf("%c-%c%c%c-%c%c%c%c%c-%c",a,b,c,d,e,f,g,h,i,ans==10?'X':ans+'0');
    return 0;
}

by 违规用户名971024 @ 2024-02-25 11:12:15

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a,b,c,d,e,f,g,h,i,j;
    int ans=0;
    scanf("%c-%c%c%c-%c%c%c%c%c-%c",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
    ans=(a-'0')*1+(b-'0')*2+(c-'0')*3+(d-'0')*4+(e-'0')*5+(f-'0')*6+(g-'0')*7+(h-'0')*8+(i-'0')*9;
    ans%=11;
    if(j=='X'&&ans==10||ans==j-'0') cout<<"Right";
    else printf("%c-%c%c%c-%c%c%c%c%c-%c",a,b,c,d,e,f,g,h,i,ans==10?'X':ans+'0');

    return 0;
}

by 违规用户名971024 @ 2024-02-25 11:13:20

我的AC代码@jaxx666666


by 违规用户名971024 @ 2024-02-25 11:14:16


|