happy_lion @ 2024-10-04 21:25:27
#include<bits/stdc++.h>
using namespace std;
int main() {
string a;
cin >> a;
int c = 0;
int s = 1;
for (int i=0;i<9;i++) {
if (a[i] == '-') {
continue;
} else {
c += (a[i]-'0')*s;
s++;
}
}
c %= 11;
if (a[12] == 'X') {
if (c == 10) {
cout << "Right";
return 0;
}
} else if (c == a[12]-'0') {
cout << "Right";
return 0;
}
for (int i=0;i<12;i++) {
cout << a[i];
}
if (c == 10) {
cout << 'X';
} else {
cout << c;
}
}
要求:在我的代码上改 必关
by kkksc_tbh @ 2024-10-04 21:30:38
#include<bits/stdc++.h>
using namespace std;
char c;
char s[14];
int main(){
cin>>s;
int h=0,k=0;
for(int i=0;i<11;i++){
if(s[i]!='-'){
k++;
h+=k*(s[i]-'0');
}
}
h%=11;
if(h==10) c='X';
else c=h+'0';
if(c==s[12]) cout<<"Right"<<endl;
else{
s[12]=c;
cout<<s;
}
return 0;
}
很久以前写的代码了,具体思路不记得了