chenaex @ 2024-10-06 11:15:03
#include<bits/stdc++.h>
using namespace std;
int main(){
char c[13];
cin>>c;
int x=1;
int n=0;
for(int i=0;i<12;i++){
if(c[i]=='-'){
continue;
}
n+=(c[i]-'0')*x;
x++;
}
n%=11;
int z;
if(c[12]=='X')
{
z=10;
}
else{
z=int(c[12]);
}
if(z==n){
cout<<"Right"<<endl;
}
else
{
for(int i=0;i<12;i++)
{
cout<<c[i]<<endl;
}
if(n==10)
{
cout<<'X'<<endl;
}
else
{
cout<<char(n+48);
}
}
return 0;
}
by chenaex @ 2024-10-06 14:27:48
@chenaex 没人回吗?
by I2147483647I @ 2024-10-08 20:44:27
by I2147483647I @ 2024-10-08 20:48:19
@chenaex
by I2147483647I @ 2024-10-08 20:55:46
哦,我知道了:你在输出的时候,本应无分隔符,你的程序里却打了endl AC Code:
#include<bits/stdc++.h>
using namespace std;
int main(){
char c[13];
cin>>c;
int x=1;
int n=0;
for(int i=0;i<12;i++){
if(c[i]=='-'){
continue;
}
n+=(c[i]-'0')*x;//这里你倒记住了
x++;
}
n%=11;
int z;
if(c[12]=='X')
{
z=10;
}
else{
z=int(c[12]-'0');//<-此处有修改!
}
if(z==n){
cout<<"Right"<<endl;
}
else
{
for(int i=0;i<12;i++)
{
cout<<c[i];//修改!
}
if(n==10)
{
cout<<'X'<<endl;
}
else
{
cout<<char(n+'0');//建议此处也如此换成‘0’哦!
}
}
return 0;
}