H - Identity Card

Do you own an ID card?You must have a identity card number in your family’s Household Register. From the ID card you can get specific personal information of everyone. The number has 18 bits,the first 17 bits contain special specially meanings:the first 6 bits represent the region you come from,then comes the next 8 bits which stand for your birthday.What do other 4 bits represent?You can Baidu or Google it.

Here is the codes which represent the region you are in.

Zheijing 330000 Beijing 110000 Taiwan 710000 Hong Kong 810000
Maocao 820000 Tibet 540000 Liaoning 210000 Shanghai 310000

However,in your card,maybe only 33 appears,0000 is replaced by other numbers.
Here is Samuel’s ID number 331004198910120036 can you tell where he is from?The first 2 numbers tell that he is from Zhengjiang Province,number 19891012 is his birthday date (yy/mm/dd).

Input

Input will contain 2 parts:
A number n in the first line,n here means there is n test cases. For each of the test cases,there is a string of the ID card number.

Output

Based on the table output where he is from and when is his birthday. The format you can refer to the Sample Output.

Sample Input

1
330000198910120036

Sample Output

He/She is from Zhejiang,and his/her birthday is on 10,12,1989 based on the table.
起初,做这道题目出现的错误是在字符串赋值那里,我直接写成了c=”Zhejiang”;这样就出现了错误,下面说一下字符串赋值;
char *a=”Zhejiang”,
也可以 char*a;a=”Zhejiang”;(用字符指针指向一个字符串)
还可以 char a[]=”Zhejiang”;(用字符数组存放一个字符串)
char a[20]=”Zhejaing”;这样是正确的
char a[20];a=”Zhejaing”,这样赋值是错误的
这种情况容易出现,a虽然是指针,但是它已经指向在堆栈中分配的20个字符空间,现在这个情况a又指向数据区中的hello常量,这里的指针a出现混乱,不允许!
注:不能先定义再赋值;
还可以利用函数 strcpy来给字符串赋值
char a[20];
strcpy(a,”Zhejaing”);
比较两字符串 要用strcmp()函数

#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
int main()
{int n,i,j,k,l;int len;char a[20];char b[20];char c[20];char d[20];char e[20];char f[20];scanf("%d",&n);while(n--){scanf("%s",a);len=strlen(a);j=0;k=0;l=0;for(i=0;i<2;i++){b[i]=a[i];}b[i]='\0';if(strcmp(b,"33")==0){strcpy(c,"Zhejiang");}else if(strcmp(b,"82")==0){strcpy(c,"Macao");}else if(strcmp(b,"11")==0){strcpy(c,"Beijing");}else if(strcmp(b,"54")==0){strcpy(c,"Tibet");}else if(strcmp(b,"71")==0){strcpy(c,"Taiwan");}else if(strcmp(b,"21")==0){strcpy(c,"Liaoning");}else if(strcmp(b,"81")==0){strcpy(c,"Hong Kong");}else if(strcmp(b,"31")==0){strcpy(c,"Shanghai");}for(i=6;i<10;i++){d[j++]=a[i];}d[j]='\0';for(i=10;i<12;i++){e[k++]=a[i];}e[k]='\0';for(i=12;i<14;i++){f[l++]=a[i];}f[l]='\0';printf("He/She is from %s,and his/her birthday is on %s,%s,%s based on the table.\n",c,e,f,d);}return 0;
}

H - Identity Card相关推荐

  1. H - Square Card HDU - 7063

    H - Square Card HDU - 7063 题意: 有两个圆形区域,一个是得分区域,一个是获得奖金区域,现在你有一个边长为a的正方形,当正方形在如果在某一时刻它严格在圆形范围内,才算合法. ...

  2. 【acm2629】 Identity Card

    **题目: Problem Description Do you own an ID card?You must have a identity card number in your family' ...

  3. 杭电OJ 2629 Identity Card(C++)

    Identity Card Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...

  4. HDU 2629 Identity Card

    简单题 给出身份证号 判断住址 和出生年月 熟练字符串的操作 主要是string::substr(s, l)//s:起始位置 l长度 1 #include <iostream> 2 #in ...

  5. Identity Card

    感觉直接字符匹配就可以了. #include<stdio.h> #include<string.h>char area(char a, char b) {char c;swit ...

  6. Identity Card(hdu2629)

    输入方式:先输入一个整型,再输入不带空格未知长度/已知长度的字符串. 思考:用scanf_s()函数输入整型,再循环输入不带空格未知长度的字符串,用gets_s()函数. 注意:scanf_s()函数 ...

  7. HDU 1.2.7 Identity Card

    这个题其实很简单,主要是处理数据,给大家分享一下处理数据的一中方法: 分别用C和C++两种方法实现,很是不错哈. #include <iostream> #include <stri ...

  8. hdu 2629 Identity Card (字符串解析模拟题)

    这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿; 题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了: http://acm.hdu.edu.cn/showproblem.ph ...

  9. 【2629】Identity Card 【比较坑 / 水题】

    http://acm.hdu.edu.cn/showproblem.php?pid=2629 地区只要看前两位就可以了,因为地区是个大的概念后面的数字代表的是县 #include<cstdio& ...

最新文章

  1. 腾讯云数据库副总监:图数据库好在哪?该用在哪?
  2. [Linux实用工具]Ubuntu环境下SSH的安装及使用
  3. 文本处理三剑客之sed
  4. VTK:PolyData之FitSplineToCutterOutput
  5. Spring AOP的一个具体例子
  6. 安装OpenCL和AMD驱动程序
  7. mysql统计同一字段重复的个数
  8. 隐藏的图片在浏览器中的请求
  9. Java 学生管理系统 GUI txt文件存储
  10. i春秋Web渗透测试工程师(初级)学习笔记(第三章)
  11. 大数据时代的“小数据”
  12. 微信html下拉刷新页面,微信公众号内的页面的下拉刷新,兼容手机端和PC端
  13. 最新微信公众号文章数据导出软件工具
  14. 金蝶EAS_WFLL2开发记录
  15. 大数据架构师拿年薪50W的方法诀窍
  16. opera浏览器修改默认搜索引擎为百度
  17. 工业智能网关BL110应用之61:如何实现智能楼宇控制BACnet 接入华为云平台
  18. node-bindings无法在Electron中使用的解决办法
  19. 给公司搭建一个人才库系统,前台(信息填写+简历上传)后台(筛选功能+下载简历)
  20. mysql——中文数字排序的实现(FIELD)

热门文章

  1. 蓝桥杯——从新手入门开始
  2. OceanBase数据库创始人阳振坤分享征战6088万tpmC的艰辛之路
  3. (阿里云笔记)贝勾置阿里云轻量应用服务器CentOS7.6镜像——Linux系统
  4. 免打轴~半自动制作文字类游戏视频的翻译字幕♥ || V1.1 ET/BT Python实例
  5. Opencv2.4.9源码分析——Stitching(二)
  6. 基于51单片机的7键电子琴音乐播放器proteus
  7. php星空背景动态,JS实现动态星空背景效果
  8. let const var 总结
  9. 劲舞团登陆不上消息服务器,《劲舞团》在内的多款产品服务器无法登陆
  10. vue安装依赖报serve: `vue-cli-service serve`