yjy_fywy @ 2024-09-17 15:55:53
只会这么写qaq
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,f,g,h,i,qwe,j1;
char q,j;
cin>>a>>q>>b>>q>>e>>q>>j;
if(j==130){
j1=10;
}else{
j1=j-48;
}
d=b%10,c=b/10%10,b/=100;
i=e%10,h=e/10%10,g=e/100%10,f=e/1000%10,e/=10000;
qwe=a+b*2+c*3+d*4+e*5+f*6+g*7+h*8+i*9;
qwe%=11;
if(qwe==j1){
cout<<"Right";
}else{
cout<<a<<"-"<<b<<c<<d<<"-"<<e<<f<<g<<h<<i<<"-"<<qwe;
}
return 0;
}
by lpsz2024wcs @ 2024-09-17 17:46:27
@yjy_fywy 这地狱马蜂
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e,f,g,h,i,qwe,j1;
char q,j,k;
cin>>a>>q>>b>>q>>e>>q>>j;
if(j=='X'){
j1=10;
}else{
j1=j-'0';
}
d=b%10,c=b/10%10,b/=100;
i=e%10,h=e/10%10,g=e/100%10,f=e/1000%10,e/=10000;
qwe=a+b*2+c*3+d*4+e*5+f*6+g*7+h*8+i*9;
qwe%=11;
if(qwe==10){
k='X';
}else if(qwe<10){
k=qwe+'0';
}
if(k!=j){
cout<<a<<"-"<<b<<c<<d<<"-"<<e<<f<<g<<h<<i<<"-"<<k;
}else{
cout<<"Right";
}
return 0;
}
by lpsz2024wcs @ 2024-09-17 17:54:51
@yjy_fywy char数组+循环结构会更好用
#include<bits/stdc++.h>
using namespace std;
int main() {
char isbn[15];
int ans=0,x=1;
cin>>isbn;
for(int i=0;i<12;i++){
if(isbn[i]!='-'){
if(isbn[i]!='X'){
ans+=x*(isbn[i]-'0');
x++;
}else{
ans+=x*10;
x++;
}
}
}
ans%=11;
if(ans==isbn[12]-'0'||(isbn[12]=='X'&&ans==10)) cout<<"Right";
else{
for(int i=0;i<=11;i++){
cout<<isbn[i];
}
if(ans!=10) cout<<ans;
else cout<<"X";
}
return 0;
}
by Luogu_Wangzhi @ 2024-09-17 18:30:08
?
by yjy_fywy @ 2024-09-18 21:26:52
@lpsz2024wcs 感谢