花花的世界。。。。。。

P1055 [NOIP2008 普及组] ISBN 号码

_Glassy_Sky_ @ 2023-08-03 19:54:36

#include<bits/stdc++.h>
using namespace std;
int main()
{
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s;
    int cnt = 1, ans = 0;
    cin >> s;
    for(int i = 0; i < s.size() - 2; i ++)
    {
        if(s[i] != '-')
        {
            int x = int(s[i]) - 48;
            ans += cnt * x;
            cnt ++;
        }
    }
    int sum = ans % 11;
    if(s[s.size() - 1] == 'X')
        if(sum == 10)
        {
            cout << "Right";
            return 0;
        }
        else
        {
            for(int i = 0; i < s.size() - 1; i ++)
                cout << s[i];
            cout << sum;
            return 0;
        }
    else
        if(int(s[s.size() - 1] - 48) == sum)
        {
            cout << "Right";
            return 0;
        }
        else
        {
            for(int i = 0; i < s.size() - 1; i ++)
                cout << s[i];
            cout << sum;
            return 0;
        }
    return 0;
}

by dingzj2022 @ 2023-08-03 20:07:18

@FZwangmuem 啥代码呀;

#include <bits/stdc++.h>
using namespace std;
int main(){
    char c1,c2,c3,c4,c5,c6,c7,c8,c9,c;
    scanf("%c-%c%c%c-%c%c%c%c%c-%c",&c1,&c2,&c3,&c4,&c5,&c6,&c7,&c8,&c9,&c);
    int ans;
    ans=(c1-48)+(c2-48)*2+(c3-48)*3+(c4-48)*4+(c5-48)*5+(c6-48)*6+(c7-48)*7+(c8-48)*8+(c9-48)*9;
    if(ans%11==(c-48) || ans%11==10 && c=='X') cout<<"Right";
    else {
        if(ans%11==10) c='X';
        else c='0'+ans%11;
        printf("%c-%c%c%c-%c%c%c%c%c-%c",c1,c2,c3,c4,c5,c6,c7,c8,c9,c);
    }
    return 0;
}

看我的,你那个太low了,给个关QWQ


by 15167987933yy @ 2023-08-05 14:24:37

@dingzj2022 呃你那个也太奇怪了吧?能AC吗?


by dingzj2022 @ 2023-08-05 14:28:09

@15167987933yy 能


by 15167987933yy @ 2023-08-05 14:34:49

@dingzj2022 呃,佩服佩服୧(๑•̀◡•́๑)૭


by _Glassy_Sky_ @ 2023-08-14 21:11:27

@dingzj2022 您能告诉我我错在哪里了吗


|