DCzzy @ 2024-10-12 17:21:42
#include<iostream>
using namespace std;
char a[13];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for (int i=1;i<=11;i++) cin>>a[i];
int k=0,h=0;
if (a[13]=='X') a[13]=10;
for (int i=1;i<=11;i++)
{
if(a[i]!='-'){
k++;
h+=k*(a[i]-'0');
}
}
int dqm=(a[1]*1+a[3]*3+a[4]*4+a[5]*5+a[7]*7+a[8]*8+a[9]*9)%11;
if (a[13]==dqm) cout<<"Right";
if (a[13]==10) cout<<a[1]<<"-"<<a[3]<<a[4]<<a[5]<<"-"<<a[7]<<a[8]<<a[9]<<"-"<<"X";
else if (a[13]!=dqm)cout<<a[1]<<"-"<<a[3]<<a[4]<<a[5]<<"-"<<a[7]<<a[8]<<a[9]<<"-"<<dqm;
return 0;
}
by LYZ0602 @ 2024-10-12 17:36:56
@DCzzy Let me look look;
by LYZ0602 @ 2024-10-12 17:39:45
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[14],c;
int sum=0,ans=0;//ans是倍数,sum是和值;
cin>>a;
for(int i=0;i<=11;i++)
{
if(a[i]!='-')
{
sum += (++ans) * (a[i] - '0');
}
}
sum%=11;
if(sum==10) c='X';
else c=sum+'0';
if(c==a[12]) cout<<"Right"<<endl;
else a[12]=c , cout<<a;
return 0;
}
@DCzzy
by DCzzy @ 2024-10-12 17:41:10
@LYZ0602 关注了 谢谢~
by LYZ0602 @ 2024-10-12 17:43:53
@DCzzy 我的代码没你这么繁琐啊
by LYZ0602 @ 2024-10-12 17:46:44
@DCzzy 给你加个注释
by LYZ0602 @ 2024-10-12 17:48:02
@DCzzy 能看懂吗?(我觉得应该没什么问题)
by DCzzy @ 2024-10-12 17:48:36
@LYZ0602 嗯
by LYZ0602 @ 2024-10-12 17:49:03
@DCzzy 那就好