HDU 2629 Identity Card

题目:http://acm.hdu.edu.cn/showproblem.php?pid=2629

类似识别身份证,每个字段都有其意义.这里用了STL - MAP简化程序

#pragma warning (disable:4786)
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{  
    int n;
    string s;
//    freopen("test.txt","r",stdin);
    map<int,string> m;
    m[33]="Zhejiang";
    m[11]="Beijing";
    m[71]="Taiwan";
    m[81]="Hong Kong";
    m[82]="Macao";
    m[54]="Tibet";
    m[21]="Liaoning";
    m[31]="Shanghai";
    cin>>n;
    for(;n--;)
    {
        cin>>s;
        int pos=(s[0]-'0')*10+s[1]-'0';
        cout<<"He/She is from ";
        cout<<m[pos];
        cout<<",and his/her birthday is on ";
        printf("%c%c,%c%c,%c%c%c%c",s[10],s[11],s[12],s[13],s[6],s[7],s[8],s[9]);
        cout<<" based on the table."<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/destino74/p/3327805.html