qixiuyuan123 @ 2024-07-14 11:45:45
#include<iostream>
using namespace std;
int t;
char a[12],mod[12]="0123456789X";
int main()
{
cin>>a;
for(int i=0,j=0;i<12;i++)
if(a[i]=='-')
continue;
else
t+=(a[i]-'0')*++j;
if(mod[t%11]==a[12])
printf("\nRight");
else
{
a[12]=mod[t%11];
cout<<a;
}
return 0;
}
by Phoenix114514 @ 2024-07-14 12:05:40
#include<bits/stdc++.h>
using namespace std;
string s;
int n,sum,k=1;
int main(){
cin>>s;
char mod[12]={'0','1','2','3','4','5','6','7','8','9','X'};
for (int i=0;i<12;i++){
if (s[i]!='-')sum=sum+(s[i]-'0')*(k++);
}
if (mod[sum%11]==s[12])cout<<"Right";
else{
s[12]=mod[sum%11];
cout<<s;
}
return 0;
}
by Phoenix114514 @ 2024-07-14 13:45:11
@qixiuyuan123 错误一: for 循环最好加上大括号。
错误二: printf 前面为什么要有 \n 换行呢?
#include<bits/stdc++.h>
using namespace std;
int t;
char mod[12]={'0','1','2','3','4','5','6','7','8','9','X'};
string a;
int main(){
cin>>a;
for(int i=0,j=0;i<12;i++){
if(a[i]=='-')continue;
else t+=(a[i]-'0')*++j;
}
if(mod[t%11]==a[12])printf("Right");
else{
a[12]=mod[t%11];
cout<<a;
}
return 0;
}
by Phoenix114514 @ 2024-07-14 15:03:51
@qixiuyuan123 rt
by qixiuyuan123 @ 2024-07-14 16:42:57
谢谢大佬(但是不加花括号能过),关了