思路:这道题按正常验证步骤做就行,没有坑点
代码如下:
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int in_1,sum=0;
cin>>in_1;
bool ifNext = true;
bool ifHaveNo = false;
string str_1;
char cs[] = {'1','0','X','9','8','7','6','5','4','3','2'};
int ns[] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
for(int x=0;x<in_1;x++){
cin>>str_1;
for(int y=0;y<17;y++){
if(str_1[y]>='0'&&str_1[y]<='9'){
sum = sum + ((str_1[y]-'0') * ns[y]);
}
else{
ifNext = false;
break;
}
}
if(ifNext == true){
if(cs[sum%11]!=str_1[17]){
ifHaveNo = true;
cout<<str_1<<endl;
}
}
else{
ifHaveNo = true;
cout<<str_1<<endl;
}
ifNext = true;
sum = 0;
}
if(ifHaveNo==false){
cout<<"All passed";
}
return 0;
}
提交结果: