AC代码

#include <cstdio>
#include <iostream>
using namespace std;
const int max_n = 110;
//权重
int W[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
//验证码
char M[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
int n;
char a;
scanf("%d", &n); int num = 0; //问题身份证数量
char err[max_n][18] = {0}; //存储问题身份证号
for(int i = 0; i < n; i++) {
bool flag = true;
char temp[18] = {0};
int sum = 0, t = 0; //t:计数正确的身份证号
//printf("%d:", i);
for(int j = 0; j < 18; j++) { //读取身份证号
cin >> a;
temp[j] = a;
}
for(int h = 0; h < 17; h++) {
//printf("%c", temp[h]);
if(!(temp[h] >= '0' && temp[h] <='9')){
//printf("break:%c\n", temp[h]);
break;
}
int n = temp[h] - '0';
//printf(" n: %d ", n);
sum += n * W[h];
t++;
}
// printf("\n");
// printf("t:%d ", t);
if(t < 17) flag = false;
for(int h = 0; h < 18; h++) {
err[i][h] = temp[h];
}
if(M[sum % 11] != temp[17]) flag = false;//验证码不等于身份证号最后一位
//printf("flag = %d, sum = %d\n", flag, sum);
if(flag == 0) { //存储问题身份证号
for(int j = 0; j < 18; j++) {
err[num][j] = temp[j];
}
num++; //问题身份证数量加一
}
}
if(num == 0) {
printf("All passed"); //身份证全部正确
} else if(num != 0){
//printf("%d\n", num);
for(int h = 0; h <= num - 1; h++) {
for(int j = 0; j < 18; j++) {
printf("%c", err[h][j]);
}
printf("\n");
}
}
return 0;
}

最新文章

  1. (转)TeamCity配置笔记
  2. centos Supervisor
  3. 基于内容的自适应变长编码[CAVLC]
  4. hihoCoder 1388 Periodic Signal(FFT)
  5. cocos2d(x) HTML label ;CCHTML CCHTMLLabel
  6. Spring 基础知识(三)MVC 架构简介
  7. Mvc校验用户没有登录就跳转的实现
  8. Fiddler中显示IP方法
  9. reactnative的js里的super的作用
  10. Hello SIP Protocol
  11. linux 查看磁盘读写:iotop
  12. Django is not importable in this environment
  13. visual studio的试用版评估期已结束 解决办法
  14. [Delphi]实现使用TIdHttp控件向https地址Post请求[转]
  15. angular学习笔记(三十一)-$location(2)
  16. INTEL
  17. Word操作(基于word2013)【非编程类】
  18. linux 冒号用法
  19. 使用gradle打包时将依赖也合并入jar包
  20. css之postion定位

热门文章

  1. NOIP模拟9
  2. C++类中函数(构造函数、析构函数、拷贝构造函数、赋值构造函数)
  3. Win10 + CLion + 树莓派 + QT 远程开发调用Python
  4. Java-JPDA 概述
  5. css3_1
  6. Mysql查询某字段重复值并删除重复值
  7. [转]Nginx实现高并发的原理
  8. Win10蓝牙鼠标老是断连卡顿的解决方法
  9. Java堆大小[z]
  10. python之scrapy模块pipelines