PAT乙级1031

https://pintia.cn/problem-sets/994805260223102976/problems/994805290334011392

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<string.h>
 4 #include<algorithm>
 5 #include<cmath>
 6 #include<vector>
 7 #include<queue>
 8 #include<bits/stdc++.h>
 9 using namespace std;
10 int n;
11 bool flag;
12 int a[17]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
13 char r[11]={'1','0','X','9','8','7','6','5','4','3','2'};
14 vector<string> b;
15 int main()
16 {
17     cin>>n;
18     int tot=0;
19     string m;
20     for(int i=0;i<n;i++)
21     {
22         flag=0;
23         int ans=0;
24         cin>>m;
25         for(int j=0;j<17;j++)
26         {
27             if(m[j]<'0'||m[j]>'9')
28             {
29                 flag=1;break;
30             }
31             ans+=a[j]*(m[j]-'0');
32         }
33         int t=ans%11;
34         if(r[t]!=m[17])
35             flag=1;
36         if(flag==1)
37             {b.push_back(m);tot++;}
38     }
39     if(tot){
40         for(vector<string>::iterator i=b.begin();i!=b.end();i++)
41         cout<<*i<<endl;
42     }
43     else
44         cout<<"All passed";
45     return 0;
46 }

 

转载于:https://www.cnblogs.com/zuiaimiusi/p/10877045.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值