zhangshibo678 @ 2022-07-21 08:24:08
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
int sum=1,w=0;
string st;
getline(cin,st);
int l=st.size();
for(int i=0;i<l-1;i++){
if(st[i]!='-'){
w+=(st[i]-'0')*sum;
sum++;
}
}
//cout<<w%11<<endl;
int x=st[l-1]-'0';
if(w%11==x){
cout<<"Right";
return 0;
}
else {
if(w%11==10&&st[l-1]=='X'){
cout<<"Right";
return 0;
}
else{
for(int i=0;i<l-1;i++){
cout<<st[i];
}
if(w%11!=10) cout<<w%11;
else cout<<"X";
}
}
return 0;
}
by 王默 @ 2022-07-21 11:48:21
#include<bits/stdc++.h>
using namespace std;
int main()
{
int sum=1,w=0;
string st;
cin>>st;
int l=st.size();
for(int i=0;i<l-1;i++)
{
if(st[i]!='-')
{
w+=(st[i]-'0')*sum;
sum++;
}
}
w%=11;
int x=int(st[l-1]-'0');
if(w==x)
{
cout<<"Right";
return 0;
}
if(w==10&&st[l-1]=='X')
{
cout<<"Right";
return 0;
}
for(int i=0;i<l-1;i++)
{
cout<<st[i];
}
if(w!=10)
{
cout<<w;
}
else
{
cout<<"X";
}
return 0;
}
return 0之后就不要else了
by 王默 @ 2022-07-21 11:48:28
@zhangshibo521
by zhangshibo678 @ 2022-07-21 14:11:12
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
int sum=1,w=0;
string st;
getline(cin,st);
int l=st.size();
for(int i=0;i<l-1;i++){
if(st[i]!='-'){
w+=(st[i]-'0')*sum;
sum++;
}
}
int x=st[l-1]-'0';
if(w%11==x){
cout<<"Right";
return 0;
}
if(w%11==10&&st[l-1]=='X'){
cout<<"Right";
return 0;
}
for(int i=0;i<l-1;i++){
cout<<st[i];
}
if(w%11!=10) cout<<w%11;
else cout<<"X";
return 0;
}
//麻烦看一下为什么AC不了
by zhangshibo678 @ 2022-07-21 14:11:42
@王默
by 王默 @ 2022-07-21 14:59:27
@zhangshibo521
把getline换成cin就对了
by zhangshibo678 @ 2022-07-21 15:12:05
@王默 感谢 已经AC