0120cy @ 2024-08-09 09:41:08
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
char p;
int a,num[15],word[15];
vector<int>k;
signed main()
{
memset(num,false,sizeof(num));
for(unsigned i=1;i<=13;i++)
{
cin>>p;
if(p<='9'&&p>='0')
{
k.push_back(p-48);
word[i]=p-48;
}
if(p=='-')
{
num[i]++;
}
}
int cnt=9,n,tot=0,m=k.back();
k.pop_back();
while(!k.empty())
{
n=k.back();
tot+=n*cnt;
k.pop_back();
cnt--;
}
if(tot%11!=m)
{
for(int i=1;i<13;i++)
{
if(num[i])cout<<'-';
else cout<<word[i];
}
cout<<tot%11;
}
else cout<<"Right";
return 0;
}
怎么答案对了却这么多红,求调
by Greeper @ 2024-08-09 09:48:55
@0120cy
#include<iostream>
using namespace std;
int main()
{
int a,b,c,e;
char x,y,z,d;
cin>>a>>x>>b>>y>>c>>z>>d;
if(d!='X')
{
e=int(d-'0');
}
else
{
e=10;
}
int m=a*100000000+b*100000+c;
int id=0;
int i=9;
while(i)
{
id+=m%10*i;
m/=10;
i--;
}
if(id%11==e)
{
cout<<"Right";
}
else
{
cout<<a<<'-'<<b<<'-'<<c<<'-';
if(id%11==10)
{
cout<<'X';
}
else
{
cout<<id%11;
}
}
return 0;
}
其实不用容器,变量就行\ 求关注,谢谢
by jza110228 @ 2024-08-09 09:51:02
正经人都是发代码的 你p判断有误 最后一位也判断进去了
#include <bits/stdc++.h>
using namespace std;
int main()
{
char s[14],a;
cin>>s;
int sum=0,k=0;
for(int i=0;i<11;i++)
{
if(s[i]!='-')
{
k++;
sum+=k*(s[i]-'0');
}
}
sum%=11;
if(sum==10) a='X';
else a=sum+'0';
if(a==s[12]) cout<<"Right"<<endl;
else
{
s[12]=a;
cout<<s;
}
return 0;
}
by 0120cy @ 2024-08-09 09:52:44
@Greeper 谢谢,但是我感觉容器简单一点耶
by 0120cy @ 2024-08-09 10:03:13
@jza110228 okok