#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int w[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char m[20]={'1','0','X','9','8','7','6','5','4','3','2'};
int n;
scanf("%d",&n);
int j;
bool flag=true;
char s[20];
int count=0;
while(n--)
{
scanf("%s",s);
int t=0;
for(int i=0;i<17;i++)
{
if(s[i]<'0'||s[i]>'9')
{
break;
}
else
{
t+=(s[i]-'0')*w[i];
}
}
if(i<17)
{
flag=false;
printf("%s\n",s);
}
else
{
if(s[17]!=m[t%11])
//count++;
// else
{
flag=false;
printf("%s\n",s);
}
}
}
if(flag==true)
printf("All passed\n");
return 0;
}
把权值和字符放进数组相乘,这样会更简便