hhjhaojie @ 2024-12-19 15:30:48
#include<bits/stdc++.h>
using namespace std;
int main(){
int s,t,r;
char a,b,c,d,e,f,g,h,i,j;
char k,l,m;
cin>>a>>k>>b>>c>>d>>l>>e>>f>>g>>h>>i>>m>>j;
s=(a-'0')*1+(b-'0')*2+(c-'0')*3+(d-'0')*4+(e-'0')*5+(f-'0')*6+(g-'0')*7+(h-'0')*8+(i-'0')*9;
t=s%11;
r=j-'0';
if(t==r)
cout<<"Right";
else
cout<<a<<k<<b<<c<<d<<l<<e<<f<<g<<h<<i<<m<<t;
}
by ATRC_ksviafly @ 2024-12-19 16:03:24
#include<cstdio>
using namespace std;
int main(){
char a,b,c,d,e,f,g,h,i,j;
int check;
scanf("%c-%c%c%c-%c%c%c%c%c-%c",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j);
check=(a-'0')*1+(b-'0')*2+(c-'0')*3+(d-'0')*4+(e-'0')*5+(f-'0')*6+(g-'0')*7+(h-'0')*8+(i-'0')*9;
check%=11;
if(j=='X'&&check==10||check==j-'0')
printf("Right\n");
else
printf("%c-%c%c%c-%c%c%c%c%c-%c",a,b,c,d,e,f,g,h,i,check==10?'X':check+'0');
return 0;
}
@hhjhaojie
C
by GuaiRen @ 2024-12-19 16:04:11
如果余数为
10 ,则识别码为大写字母X 。修改后代码
#include<bits/stdc++.h> using namespace std; int main() { long long s; char a, b, c, d, e, f, g, h, i, j; char k, l, m, t; cin >> a >> k >> b >> c >> d >> l >> e >> f >> g >> h >> i >> m >> j; s = (a - '0') * 1 + (b - '0') * 2 + (c - '0') * 3 + (d - '0') * 4 + (e - '0') * 5 + (f - '0') * 6 + (g - '0') * 7 + (h - '0') * 8 + (i - '0') * 9; s %= 11; if (s == 10) t = 'X'; else t = to_string(s)[0]; if (t == j) cout << "Right" << endl; else cout << a << '-' << b << c << d << '-' << e << f << g << h << i << '-' << t << endl; return 0; }
by hhjhaojie @ 2024-12-19 16:18:29
@GuaiRen感谢感谢
by gac497 @ 2024-12-19 16:25:24
@hhjhaojie
千万别漏掉我写的!!!
一道很有意思的题,建议好好思考为什么这么做
#include<bits/stdc++.h>
using namespace std;
int main(){
int s,t,r;
char a,b,c,d,e,f,g,h,i,j;
char k,l,m;
cin>>a>>k>>b>>c>>d>>l>>e>>f>>g>>h>>i>>m>>j;
s=(a-'0')*1+(b-'0')*2+(c-'0')*3+(d-'0')*4+(e-'0')*5+(f-'0')*6+(g-'0')*7+(h-'0')*8+(i-'0')*9;
t=s%11;
r=j;//原 r=j-'0';
if(t==10 && r=='X' || t==j-'0')//原 if(t==r)
cout<<"Right";
else
cout<<a<<k<<b<<c<<d<<l<<e<<f<<g<<h<<i<<m,t==10?cout<<'X':cout<<t;//原 cout<<a<<k<<b<<c<<d<<l<<e<<f<<g<<h<<i<<m<<t;
}
改动点已标注