Atwi_llljx @ 2022-11-20 12:19:31
#include<bits/stdc++.h>
using namespace std;
int main()
{
int s[9],b,bb=0;
scanf("%1d-%1d%1d%1d-%1d%1d%1d%1d%1d-%1d",&s[0],&s[1],&s[2],&s[3],&s[4],&s[5],&s[6],&s[7],&s[8],&b);
for(int i=0,j=1;i<9;bb+=s[i]*j,j++,i++);
bb=bb%11;
if(b==bb)
cout<<"Right";
else if(bb!=10)
printf("%1d-%1d%1d%1d-%1d%1d%1d%1d%1d-%1d",s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],bb);
else
printf("%1d-%1d%1d%1d-%1d%1d%1d%1d%1d-X",s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8]);
return 0;
}
by Liujiayuan3 @ 2022-11-22 21:37:25
你看是不是括号的问题?
by Liujiayuan3 @ 2022-11-22 22:22:47
C++的话for循环,if等都需要写大括号。for(int i=0;i<=a.leagth();i++){ ......; } 你试试