Yaoshui_lv @ 2024-09-26 21:35:24
#include <bits/stdc++.h>
#define n 12
using namespace std;
char m; int ans, cnt = 1;
string s;
int main() {
cin >> s;
m = s[12];
s[12] = '\0';
for (int i = 0; i < n; i++) {
if (s[i] == '-') continue;
int x = s[i]-'0';
ans += x * cnt;
cnt++;
}
ans = ans % 11;
if (ans == 10) {
if (m == 'X') cout << "Right" << endl;
else cout << s << ans << endl;
} else {
if (ans == m-'0') cout << "Right" << endl;
else {
if (ans == 10) cout << s << "X" << endl;
else cout << s << ans << endl;
}
}
return 0;
}
by Deric456 @ 2024-09-26 21:36:55
#include<bits/stdc++.h>
using namespace std;
char a[15];
int main()
{
cin>>a;
int s=(a[0]-'0')*1+(a[2]-'0')*2+(a[3]-'0')*3
+(a[4]-'0')*4+(a[6]-'0')*5+(a[7]-'0')*6+(a[8]-'0')*7
+(a[9]-'0')*8+(a[10]-'0')*9;
int t=s%11;
if(t==(a[12]-'0')||t==10&&a[12]=='X'){
cout<<"Right";
}else{
for(int i=0;i<=11;i++){
cout<<a[i];
}
if(t<10){
cout<<t;
}else{
cout<<'X';
}
}
}
AC代码,求关
by Deric456 @ 2024-09-26 21:38:10
@Yaoshui_lv
by kaoxiangnb666 @ 2024-09-26 21:38:13
你输出前面加了个空格
by Yaoshui_lv @ 2024-09-27 08:27:31
@Deric456 @kaoxiangnb666 已关谢谢