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

这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿;

题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了:

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

 1 #include <iostream>
 2 #include <string>
 3 using namespace std;
 4 int main()
 5 {
 6     int n,t;
 7     string home,a;
 8     cin>>n;
 9     for(int k = 0 ; k < n ; k++)
10     {
11         cin>>a;
12         t = (a[0]-'0')*10+a[1]-'0';
13         switch(t)
14         {
15             case 11:home = "Beijing";break;
16             case 31:home = "Shanghai";break;
17             case 21:home = "Liaoning";break;
18             case 33:home = "Zhejiang";break;
19             case 54:home = "Tibet";break;
20             case 71:home = "Taiwan";break;
21             case 81:home = "Hong Kong";break;
22             case 82:home = "Macao";break;
23             default :break;
24         }
25         cout<<"He/She is from "<<home<<",and his/her birthday is on "
26         <<a[10]<<a[11]<<","<<a[12]<<a[13]<<","<<a[6]<<a[7]<<a[8]<<a[9]
27         <<" based on the table."<<endl;
28     }
29     return 0;
30 }


 

posted @ 2013-12-10 14:34  crazy_apple  阅读(1915)  评论(0编辑  收藏  举报