hxl18320 @ 2024-11-02 12:11:39
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[13];
scanf("%s",a);
int b[10]={a[0]-'0',a[2]-'0',a[3]-'0',a[4]-'0',a[6]-'0',a[7]-'0',a[8]-'0',a[9]-'0',a[10]-'0'};
if(a[12]=='X') b[9]=10;
else b[9]=a[12]-'0';
int c=0;
for(int i=1;i<10;i++){
c+=b[i-1]*i;
}
if(c%11==b[9]) cout<<"Right";
else{
if(c%11==10){
a[12]='X';
}else{
a[12]=c%11+'0';
}
cout<<a;
}
}
------------
新手,只是单纯的问一下
by meifan666 @ 2024-11-02 12:33:04
@hxl18320 语法问题
scanf("%s",a);
改
scanf("%s",&a);
by hxl18320 @ 2024-11-02 14:11:06
@meifan666 谢谢你
by hxl18320 @ 2024-11-02 14:20:19
但好像还是有问题
?
by hxl18320 @ 2024-11-02 14:22:35
错误提示是这个(洛谷的)
Wrong Answer.wrong answer Too long on line
by hxl18320 @ 2024-11-02 15:41:24
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[20];
scanf("%s",&a);
int b[10]={a[0]-'0',a[2]-'0',a[3]-'0',a[4]-'0',a[6]-'0',a[7]-'0',a[8]-'0',a[9]-'0',a[10]-'0'};
if(a[12]=='X') b[9]=10;
else b[9]=a[12]-'0';
int c=0;
for(int i=1;i<10;i++){
c+=b[i-1]*i;
}
if(c%11==b[9]) cout<<"Right";
else{
if(c%11==10){
a[12]='X';
}else{
a[12]=c%11+'0';
}
cout<<a;
}
}