LLEeeeEe @ 2024-02-12 13:01:52
求大佬们帮忙调调 谢谢
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char a[13];
int i,j,b=0,c=0,d;
for(i=0;i<13;i++)
cin>>a[i];
b=a[0]-48+(a[2]-48)*2+(a[3]-48)*3+(a[4]-48)*4+(a[6]-48)*5+(a[7]-48)*6+(a[8]-48)*7+(a[9]-48)*8+(a[10]-48)*9;
c=b%11;
if(c==a[12]-48&&c<11)
{
cout<<"Right"<<endl;
goto F;
}
if(c==10&&a[12]=='X')
{
cout<<"Right"<<endl;
goto F;
}
if(c!=a[12]-48)
{
if(c!=a[12]-48&&c<11)
a[12]=c+48;
else
a[12]='X';
for(i=0;i<13;i++)
cout<<a[i];
}
F:
system("pause");
}
by shtian @ 2024-02-12 13:14:29
@LLEeeeEe AC记录 问题出在12和24行,吧11换成10
by shtian @ 2024-02-12 13:16:25
#include <iostream>
#include <string.h>
using namespace std;
int main() {
char a[13];
int i, j, b = 0, c = 0, d;
for (i = 0; i < 13; i++)
cin >> a[i];
b = a[0] - 48 + (a[2] - 48) * 2 + (a[3] - 48) * 3 + (a[4] - 48) * 4 + (a[6] - 48) * 5 + (a[7] - 48) * 6 +
(a[8] - 48) * 7 + (a[9] - 48) * 8 + (a[10] - 48) * 9;
c = b % 11;
if (c == a[12] - 48 && c < 10) {
cout << "Right" << endl;
return 0;
}
if (c == 10 && a[12] == 'X') {
cout << "Right" << endl;
return 0;
}
if (c != a[12] - 48) {
if (c != a[12] - 48 && c < 10)
a[12] = c + 48;
else
a[12] = 'X';
for (i = 0; i < 13; i++)
cout << a[i];
}
return 0;
}
by LLEeeeEe @ 2024-02-12 13:59:44
@shtian 谢谢 问题解决了