Subset @ 2023-10-05 20:36:50
#include<bits/stdc++.h>
using namespace std;
const int mod = 11;
string y,z;
int x,w;
int main(){
scanf("%d-%s-%s-%d",&x,&y,&z,&w);
int num = 1,ans = 0;
for(;num < y.size();num++) ans += num*(y[num]-'0');
for(;num < z.size();num++) ans += num*(z[num]-'0');
if(ans % mod == w) cout << "Right";
else cout << ans % mod;
}
QWQ
by Continu @ 2023-10-05 20:38:24
上原码
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;
int main()
{
char a[14];
scanf("%s",a);
int j=1,t=0;
for(int i=0;i<12;i++)
{
if(a[i]=='-')
{
continue;
}
t+=(a[i]-'0')*j++;
}
t=t%11;
if(t+'0'==a[12])
{
printf("Right");
}
else if(t==10&&a[12]=='X')
{
printf("Right");
}
else
{
if(t==10)
{
a[12]='X';
printf("%s",a);
}
else if(t<10)
{
a[12]=t+'0';
printf("%s",a);
}
}
return 0;
}
by Continu @ 2023-10-05 20:50:02
@Subset
字符串的输入不能用scanf,只能用cin
需要头文件#include<iostream>
或 gets()
需要头文件#include<string>
如果一定要用scanf,则要将字符串先转换为字符数组
by Subset @ 2023-10-05 20:51:26
谢谢,此帖结