Xiaqilong_Damn @ 2024-11-03 12:18:49
#include <bits/stdc++.h>
using namespace std;
int main() {
char num[12];
int sum = 0;
for (int i = 0; i <= 12; i++){
cin >> num[i];
}
int x = 1;
for (int i = 0; i <= 10; i++){
if (num[i] == '-'){
continue;
}
sum += (num[i] - '0') * x;
x++;
}
if (sum % 11 == (num[12] - '0')){
cout << "Right" << endl;
return 0;
}
for (int i = 0; i <= 11; i++){
cout << num[i];
}
cout << sum % 11 << endl;
return 0;
}
by zhangchi20121226 @ 2024-11-05 21:44:37
你这字符数组都没开够
by zhangchi20121226 @ 2024-11-05 21:51:06
是这样的```cpp
using namespace std; int main() { char num[13],n; int sum = 0,s; for (int i = 0; i <= 12; i++){ cin >> num[i]; } int x = 1; for (int i = 0; i <= 11; i++){ if (num[i] == '-'){ continue; } sum += (num[i] - '0') * x; x++; } if (num[12] == 'X'){ if(sum % 11 == 10){ cout<<"Right"; return 0; } } if (sum % 11 == (num[12] - '0')){ cout << "Right" << endl; return 0; } if(sum % 11 == 10){ n = 'X'; } else{ n = (sum % 11)+'0'; } for (int i = 0; i <= 11; i++){ cout << num[i]; } cout << n << endl; return 0; }
by zhangchi20121226 @ 2024-11-05 21:51:58
#include <bits/stdc++.h>
using namespace std;
int main() {
char num[13],n;
int sum = 0,s;
for (int i = 0; i <= 12; i++){
cin >> num[i];
}
int x = 1;
for (int i = 0; i <= 11; i++){
if (num[i] == '-'){
continue;
}
sum += (num[i] - '0') * x;
x++;
}
if (num[12] == 'X'){
if(sum % 11 == 10){
cout<<"Right";
return 0;
}
}
if (sum % 11 == (num[12] - '0')){
cout << "Right" << endl;
return 0;
}
if(sum % 11 == 10){
n = 'X';
}
else{
n = (sum % 11)+'0';
}
for (int i = 0; i <= 11; i++){
cout << num[i];
}
cout << n << endl;
return 0;
}
求关QAQ