细数繁星 @ 2023-04-01 11:15:34
RT
@OJone, @Liumingxuan2010,
#include<cstdio>
#include<cmath>
int main()
{
int a, b, c, record;
scanf("%d-%d-%d-%s", &a, &b, &c, &record);
// printf("%d", record);
if (record == 'X')
{
record = 10;
}
else if (record >= '0')
{
record -= '0';
}
int result = a * 100000000 + b * 100000 + c;
int len = (int) log10(result) + 1;
int sum = 0;
int total = len;
for (int i = 1; i < len; i++)
{
sum += (result / (int)(pow(10.0, len - i - 1)) % 10)
* (i + 2);
// printf("%d %d\n", (result / (int)(pow(10.0, len - i - 1)) % 10), i + 2);
}
// printf("%d\n", sum);
int recordpd = result % 11;
if (recordpd == record)
{
printf("%s\n", "Right");
return 0;
}
else
{
if (recordpd < 10)
{
printf("%d-%d-%d-%d", a, b, c, recordpd);
}
else
{
printf("%d-%d-%d-%s", a, b, c, "X");
}
}
return 0;
}
by 细数繁星 @ 2023-04-01 11:16:09
@OJone @Liumingxuan2010
by Indufty_666 @ 2023-04-01 11:17:04
有必要吗!?
@2044_space_elevator
by Indufty_666 @ 2023-04-01 11:18:18
#include <bits/stdc++.h>
using namespace std;
int main()
{
string isbn,mod_11 = "0123456789X";
cin >> isbn;
int x = 0;
long long mul = 0;
for(int i = 0;i < 12;i++)
{
if(isbn[i] == '-') continue;
else
{
x++;
mul = mul + int(isbn[i] - '0') * x;
}
}
if(mod_11[mul % 11] == isbn[12]) cout << "Right" << endl;
else
{
int x = mul % 11;
if(x == 10)
{
isbn[12] = 'X';
}
else
{
isbn[12] = char(x + '0');
}
cout << isbn << endl;
}
return 0;
}
by Indufty_666 @ 2023-04-01 11:18:38
@2044_space_elevator
by 细数繁星 @ 2023-04-01 11:19:17
谢谢蒟蒻
by Ancap @ 2023-04-01 11:21:12
也感觉有点烦(禁止抄袭!!!)
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,nd;char d,QW;
cin>>a>>QW>>b>>QW>>c>>QW>>d;
int temp=(a*1+b/100*2+b/10%10*3+b%10*4+c/10000*5+c/1000%10*6+c/100%10*7+c/10%10*8+c%10*9)%11;char ntemp;
if(d!='X') nd=d-'0';
else nd=10;
if(temp!=10) ntemp=temp+'0';
else ntemp='X';
if(temp==nd) cout<<"Right";
else cout<<a<<'-'<<b<<'-'<<c<<'-'<<ntemp;
}
by Indufty_666 @ 2023-04-01 11:24:10
@2044_space_elevator 你礼貌吗
by Andy_Li @ 2023-04-02 20:46:18
@Liumingxuan2010 你这不是讨论区发题解吗?不应该给别人调代码而不是让别人跟你的代码对比吗?举报了讨论区题解
by Indufty_666 @ 2023-04-02 20:48:21
@Andy_Li 我不是帮别人调代码吗
by Andy_Li @ 2023-04-02 20:50:22
@Liumingxuan2010 哪里调了?分明是把AC代码放到这里让别人自己对