Zanmu_ @ 2022-08-05 16:38:09
我这还是看了一位大佬的题解写出来的
#include<iostream>
using namespace std;
int main()
{
int i,p,sum;
int k = 1;
char str[13];
for(i = 0;i<=12;i++)
{
cin >> str[i] ;
}
for(i = 0;i<11;i++)
{
if(str[i] != '-')
{
int b=str[i];
b = b - 48;
sum = sum + k*b;
k++;
}
}
p = sum % 11;
int c=str[12]-48;
if(p == c&& str[12]>='0' &&str[12]<='9' ||p==10 &&str[12]=='X')
{
cout << "Right" << endl;
}
else
{
for(i=0;i<12;i++)
{
cout<<str[i];
}
if(p==10)
{
cout<<'X';
}
else
{
cout<<p;
}
}
return 0;
}
by Zanmu_ @ 2022-08-05 16:39:14
若输入0-670-82162-4则dev c++的运算结果为 0-670-82162-9
by xyx_37jc @ 2022-08-06 23:23:18
@Zanmu_ 你去洛谷在线IDE编译一下试试看对不对。
by Zanmu_ @ 2022-08-07 08:41:18
@xyx_37jc 程序是能运行,但输入0-670-82162-4反而输出0-670-82162-0,,,输入0-670-82162-0却输出right
by Zanmu_ @ 2022-08-07 08:55:52
@Zanmu_ 我又试了一边又对了...但我没改过代码