求助,样例过了,错误的例子也过了,为什么不能通过
查看原帖
求助,样例过了,错误的例子也过了,为什么不能通过
1345402
Amount789楼主2024/7/13 10:11
#include <bits/stdc++.h>

using namespace std;

#define length 13

int main()

{

char ar[length];

cin >> ar;

int sum = 0, j = 1;

for (int i = 0; i < length - 2; i++)

{

if (ar[i] >= '0' && ar[i] <= '9')

{

sum += (ar[i] - '0') * j;

j++;

}

}

int i_code;

i_code = sum % 11;

if (i_code == 10)

{

if (ar[length - 1] == 'X')

cout << "Right";

else

{

ar[length - 1] = '0' + 40;

cout << ar;

}

}

else

{

if (i_code + '0' == ar[length - 1])

cout << "Right";

else

{

ar[length - 1] = i_code + '0';

cout << ar;

}

}

}
2024/7/13 10:11
加载中...