| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 462 人关注过本帖
标题:杭电 ID card....
只看楼主 加入收藏
巴克
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:93
专家分:199
注 册:2012-2-8
结帖率:100%
收藏
已结贴  问题点数:14 回复次数:5 
杭电 ID card....
上题:
Problem Description
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.

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.

 
搜索更多相关主题的帖子: next specially represent everyone 
2012-02-23 22:41
巴克
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:93
专家分:199
注 册:2012-2-8
收藏
得分:0 
贴代码
程序代码:
#include<stdio.h>
#include<string.h>
int main()
{
    char ss[16][20] = {"Zhejiang\0","330000\0",
                       "Beijing\0","110000\0",
                       "Taiwan\0","710000\0",
                       "Hong Kong\0","810000\0",
                       "Macao\0","820000\0",
                       "Tibet\0","540000\0",
                       "Liaoning\0","210000\0",
                       "Shanghai\0","310000\0"
                    };
    int i,j,k,ti;
    char str[500][24],place[7],birth[5];
    int n,month,day;
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
        gets(str[i]);
        for(k=0;k<6;k++)
            place[k] = str[i][k];
        place[6] = '\0';
        for(k=6,j=0;k<10;k++,j++)
            birth[j] = str[i][k];
        birth[4] = '\0';
        month = 10*(str[i][10]-'0')+str[i][11]-'0';
        day = 10*(str[i][12]-'0')+str[i][13]-'0';
        for(ti = 0;ti<16;ti++)
        {
            if(strcmp(ss[ti],place)==0)
            {
                printf("He/She is from %s,and his/her birthday is on ",ss[ti-1]);
                printf("%d,%d,%s based on the table.\n",month,day,birth);                   //这里面分行输出时为了美观....
            }
        }
    }

    return 0;
}

2012-02-23 22:42
巴克
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:93
专家分:199
注 册:2012-2-8
收藏
得分:0 
这个代码交上去就是wrong answer
不知为什么??
原题已经AC,开贴问一下这个为什么错了....
2012-02-23 22:43
cyuyan68
Rank: 2
等 级:论坛游民
帖 子:2
专家分:15
注 册:2012-2-23
收藏
得分:10 
没问题啊,
图片附件: 游客没有浏览图片的权限,请 登录注册
先输入18,再输入证号回车ok
2012-02-25 22:59
绿石头518
Rank: 2
等 级:论坛游民
帖 子:28
专家分:65
注 册:2012-1-5
收藏
得分:0 
,学习了。
2012-02-26 08:38
beyondyf
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:3282
专家分:12654
注 册:2008-1-21
收藏
得分:0 
这道题是挺让人崩溃的。这是我的代码,没有AC,但不想改了

程序代码:
#include<stdio.h>
int main()
{
    int n, ad, t1, yy, mm, dd, t2;
    char * str[100];
    str[33] = "Zhejiang";
    str[11] = "Beijing";
    str[71] = "Taiwan";
    str[81] = "Hong Kong";
    str[82] = "Macao";
    str[54] = "Tibet";
    str[21] = "Liaoning";
    str[31] = "Shanghai";
    for(scanf("%d", &n); n--;)
    {
        scanf("%2d%4d%4d%2d%2d%4d", &ad, &t1, &yy, &mm, &dd, &t2);
        printf("He/She is from %s,and his/her birthday is on %02d,%02d,%d based on the table.\n", str[ad], mm, dd, yy);
    }
    return 0;
}

重剑无锋,大巧不工
2012-02-26 10:36
快速回复:杭电 ID card....
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032735 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved