题解:模拟题,直接算
题目地址:https://www.nowcoder.com/questionTerminal/779a72a420744b1d9c0ec7b7a8dd8f39
1 /** 2 * 3 *作者:Ycute 4 *时间:2019-11-01-15.37.01 5 *题解简单描述:直接计算即可 6 */ 7 8 9 #include<iostream> 10 #include<cmath> 11 #include<cstring> 12 #include<algorithm> 13 #include<vector> 14 using namespace std; 15 16 17 int main(){ 18 char ch[20]; 19 int t; 20 scanf("%d",&t); 21 int flag=0; 22 while(t--){ 23 getchar(); 24 scanf("%s",ch); 25 long long sum; 26 sum=(ch[0]-'0')*7+(ch[1]-'0')*9+(ch[2]-'0')*10+(ch[3]-'0')*5+(ch[4]-'0')*8+(ch[5]-'0')*4+(ch[6]-'0')*2+(ch[7]-'0')*1+(ch[8]-'0')*6+(ch[9]-'0')*3+(ch[10]-'0')*7+(ch[11]-'0')*9+(ch[12]-'0')*10+(ch[13]-'0')*5+(ch[14]-'0')*8+(ch[15]-'0')*4+(ch[16]-'0')*2; 27 sum=sum%11; 28 //cout<<sum<<endl; 29 switch(sum){ 30 case 0:{ 31 if(ch[17]!='1'){ 32 printf("%s ",ch); 33 flag=1; 34 } 35 break; 36 } 37 case 1:{if(ch[17]!='0'){ 38 printf("%s ",ch); 39 flag=1; 40 } 41 break; 42 } 43 case 2:{if(ch[17]!='x'){ 44 printf("%s ",ch); 45 flag=1; 46 } 47 break; 48 } 49 case 3:{if(ch[17]!='9'){ 50 printf("%s ",ch); 51 flag=1; 52 } 53 break; 54 } 55 case 4:{if(ch[17]!='8'){ 56 printf("%s ",ch); 57 flag=1; 58 } 59 break; 60 } 61 case 5:{if(ch[17]!='7'){ 62 printf("%s ",ch); 63 flag=1; 64 } 65 break; 66 } 67 case 6:{if(ch[17]!='6'){ 68 printf("%s ",ch); 69 flag=1; 70 } 71 break; 72 } 73 case 7:{if(ch[17]!='5'){ 74 printf("%s ",ch); 75 flag=1; 76 } 77 break; 78 } 79 case 8:{if(ch[17]!='4'){ 80 printf("%s ",ch); 81 flag=1; 82 } 83 break; 84 } 85 case 9:{if(ch[17]!='3'){ 86 printf("%s ",ch); 87 flag=1; 88 } 89 break; 90 } 91 case 10:{if(ch[17]!='2'){ 92 printf("%s ",ch); 93 flag=1; 94 } 95 break; 96 } 97 } 98 } 99 if(!flag) printf("All passed "); 100 return 0; 101 }