zoukankan      html  css  js  c++  java
  • 杭电acm Identity Card

    题目链接:http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1&sectionid=2&problemid=25

    好的吧,不得不说我因为一个Hone Kong卡了好几个小时,改来改去,使用了几种方式:1,使用hashmap保存所有的表格的数据,将身份证头两位、年、月、日转换成整数。2,使用hashmap只转换头两位,其余直接从身份证中取。3,纯粹使用网上的方法,直接将身份证的字符串输出,都是wrong answer,直到使用文本比较工具才发现了错误,233333333~~~。

    代码如下:

    #include<iostream>
    #include<cstdio>
    #include<string>
    using namespace std;
    char* arr[100];
    void init(){
    	arr[33]="Zhejiang";
    	arr[11]="Beijing";
    	arr[71]="Taiwan";
    	arr[81]="Hong Kong";
    	arr[82]="Macao";
    	arr[54]="Tibet";
    	arr[21]="Liaoning";
    	arr[31]="Shanghai";
    }
    
    int main(){
    	 int n;
    	 init();
    	 cin>>n;
    	 while(n--){
    		 char str[100];
    		 scanf("%s",str);
    		 int h=(str[0]-'0')*10+(str[1]-'0');
    		 int year = (str[6]-'0')*1000+(str[7]-'0')*100+(str[8]-'0')*10+(str[9]-'0');
    		 int month = (str[10]-'0')*10+(str[11]-'0');
    		 int day=(str[12]-'0')*10+(str[13]-'0');
    		 printf("He/She is from %s,and his/her birthday is on %02d,%02d,%04d based on the table.
    ",
    				 arr[h],month,day,year);
    	 }
    	 return 0;
    }
  • 相关阅读:
    contextMenu,右键菜单
    hashchange
    web攻击日志分析之新手指南
    工匠人生
    数学有卵用之通信篇
    精英主义(一)
    flaskbb部署笔记
    深入分析一波,你们说的云安全到底是什么鬼?
    Gh0st与云安全
    困境与突破
  • 原文地址:https://www.cnblogs.com/jackwuyongxing/p/4524507.html
Copyright © 2011-2022 走看看