50分求助,困惑了好久的题目

P1055 [NOIP2008 普及组] ISBN 号码

BreadC @ 2024-11-07 16:11:02

#include<iostream>
using namespace std;
int main()
{
    char ch[15];
    int num = 1,ans=0;
    for (int i = 1; i <= 12; i++)
    {
        cin >> ch[i];
        if (ch[i] != '-')
        {
            ans += num * (ch[i] - '0');
            num++;
        }
    }
    cin >> ch[13];
    if (ch[13] - '0' == ans % 11)
        cout << "Right";
    else
    {
        for (int i = 1; i <= 12; i++)
        {
            cout << ch[i];
        }
        cout << ans % 11;
    }
    return 0;
}

by c22j33c43 @ 2024-11-07 16:23:40

你的x呢?


by c22j33c43 @ 2024-11-07 16:24:36

如果识别码=10,要变X


by c22j33c43 @ 2024-11-07 16:24:52

@BreadC


by BreadC @ 2024-11-07 16:27:27

@c22j33c43 对不起哥,我没看题QAQ


by weiyeen0201 @ 2024-11-10 15:50:12

两个cin语句也有问题: 第一个放for循环上面,直接用cin>>ch; 第二个cin多余。


|