AC解题
2023-05-21 19:36:01
发布于:广东
17阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespaceespace std;
int main(void)
{
int a[9] = {};
int sum = 0;
char last;
scanf("%1d-%1d%1d%1d-%1d%1d%1d%1d%1d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8]);
scanf("-%1c",&last);
for (int i = 1;i <= 9;i++)
{
sum += a[i - 1] * i;
}
sum %= 11;
if (sum < 10 && sum == last - 48)
{
printf("Right");
return 0;
}
if (sum == 10 && last == 'X')
{
printf("Right");
return 0;
}
if (sum == 10)
{
last = 'X';
}
else
{
last = sum + 48;
}
printf("%1d-%1d%1d%1d-%1d%1d%1d%1d%1d-%1c",a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],last);
return 0;
}
这里空空如也
有帮助,赞一个